我有一个脚本gapminder1.py,它使用熊猫和sklern。
# 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环境,但不知道为什么它不能正常工作。
发布于 2018-07-31 08:12:10
好吧,我认为这是一个康达和碧昂斯没有好好沟通的问题。这就是为什么我总是使用PyCharm创建虚拟环境的原因。
选项1:使用PyCharm创建一个新的虚拟环境
试试jetbrains的指示。
选项2:删除并重新连接到旧的Conda环境并检查设置
也许您在通过PyCharm连接到环境时没有检查其中的一些框:
发布于 2018-11-22 17:42:24
至少在PyCharm上,这是一个已知的问题。conda环境被使用,但没有被PyCharm实际激活,因此不能加载env的环境变量。这是一个问题已经有一段时间了,似乎很容易解决,但由于某些原因,他们还没有解决它。
惟一的工作是从激活env的cmd窗口启动PyCharm,或者在执行之前作为外部工具运行环境激活。
发布于 2018-07-21 22:00:23
您必须使用py魅力设置将numpy安装到conda虚拟环境中。


https://stackoverflow.com/questions/51455571
复制相似问题