在Windows中使用Anaconda启动应用程序的绝对新手。我可以在笔记本电脑或控制台中的JupyterLabs中成功运行此代码,在Spyder中也可以正常运行,但在Pycharm中运行时出现错误:
import numpy as np
weights = np.array([0.1, 0.2, 0])
def neural_network(input, weights):
pred = input.dot(weights)
return pred
toes = np.array([8.5, 9.5, 9.9, 9.0])
wlrec = np.array([0.65, 0.8, 0.8, 0.9])
nfans = np.array([1.2, 1.3, 0.5, 1.0])
input = np.array([toes[0], wlrec[0], nfans[0]])
pred = neural_network(input, weights)
print(pred)
我收到以下错误消息:
ModuleNotFoundError: No module named 'numpy'
我需要检查什么才能了解为什么我可以访问JupyterLabs中的这个库,但不能访问PyCharm,即使这两个库都是从我的Anaconda仪表板启动的?我可以说你很好
您必须将
numpy
安装到pip install numpy
或conda install numpy
正在使用的环境中,另请参见https://numpy.org/install/您需要在pycharm中安装numpy,请参见userguide
在PyCharm中,您需要设置您正在使用的环境,以便它能够看到您已经安装的软件包。 如果在PyCharm中打开设置,您将看到以
Project: ...
开头的菜单项。在那下面,转到Project Interpreter
并添加一个新环境。这应该是为您安装Anaconda的文件夹(默认为C:\Users\<your-username>\Anaconda3\
)因此,在这种情况下,您要查找的Python可执行文件将位于
C:\Users\<your-username>\Anaconda3\bin\python
中-这可能因您安装Anaconda的位置而异相关问题 更多 >
编程相关推荐