我有一个脚本gapminder1.py,它使用pandas和scikit-learn库。
# TODO: Add import statements
import pandas as pd
from sklearn.linear_model import LinearRegression
# Assign the dataframe to this variable.
# TODO: Load the data
bmi_life_data = pd.read_csv("CSV_DATA/bmi_and_life_expectancy.csv")
print(bmi_life_data)
# Make and fit the linear regression model
#TODO: Fit the model and Assign it to bmi_life_model
bmi_life_model = LinearRegression()
bmi_life_model.fit(bmi_life_data[['BMI']], bmi_life_data[['Life expectancy']])
# Make a prediction using the model
# TODO: Predict life expectancy for a BMI value of 21.07931
laos_life_exp = bmi_life_model.predict(21.07931)
我在cmd控制台中运行脚本,一切正常,但是在pycharm中运行同样的脚本时出现错误。
C:\Users\tripathi\AppData\Local\Continuum\anaconda3\envs\dsnd\python.exe C:/Users/tripathi/PycharmProjects/dsnd/gapminder1.py
Traceback (most recent call last):
File "C:/Users/tripathi/PycharmProjects/dsnd/gapminder1.py", line 3, in <module>
import pandas as pd
File "C:\Users\tripathi\AppData\Local\Continuum\anaconda3\envs\dsnd\lib\site-packages\pandas\__init__.py", line 19, in <module>
"Missing required dependencies {0}".format(missing_dependencies))
ImportError: Missing required dependencies ['numpy']
我在两个地方使用相同的conda环境,但不确定为什么它不能正常工作。