Python 在 pycharm 上导入 numpy
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/35623776/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Import numpy on pycharm
提问by Pickeroll
I'm trying to import numpy on Pycharm.
我正在尝试在 Pycharm 上导入 numpy。
Using the Pycharm terminal and Miniconda I've launched the command:
使用 Pycharm 终端和 Miniconda 我启动了命令:
conda install numpy
And this was the output
这是输出
Fetching package metadata: ....
Solving package specifications: ....................
# All requested packages already installed.
# packages in environment at C:\Users\...\Miniconda3:
#
numpy 1.10.4 py35_0
So I run my project but the terminal said
所以我运行我的项目,但终端说
ImportError: No module named 'numpy'
On my project bar I can see two different folders, the one with my project and another one with the external libraries.
在我的项目栏上,我可以看到两个不同的文件夹,一个是我的项目,另一个是外部库。
Under External libraries -> Extendend definitions there is a numpy folder so I guess that the installation goes well.
在 External libraries -> Extendend definition 下有一个 numpy 文件夹,所以我猜安装进行得很顺利。
Can you please help me ?
你能帮我么 ?
采纳答案by Mert Cuhaci
Go to
去
- ctrl-alt-s
- click "project:projet name"
- click project interperter
- click pip
- search numpy from the top bar
- click on numpy
- click install package button
- ctrl-alt-s
- 单击“项目:项目名称”
- 单击项目互操作者
- 点击点子
- 从顶部栏中搜索 numpy
- 单击 numpy
- 单击安装包按钮
if it doesnt work this can help you:
如果它不起作用,这可以帮助您:
https://www.jetbrains.com/help/pycharm/installing-uninstalling-and-upgrading-packages.html
https://www.jetbrains.com/help/pycharm/installing-uninstalling-and-upgrading-packages.html
回答by mab
In PyCharm go to
在 PyCharm 中转到
- File → Settings, or use Ctrl+ Alt+ S
- < project name > → Project Interpreter → gear symbol→ Add Local
- navigate to
C:\Miniconda3\envs\my_env\python.exe
, where my_envis the environment you want to use
- 文件 → 设置,或使用Ctrl+ Alt+S
- <项目名称>→项目解释器→齿轮符号→添加本地
- 导航到
C:\Miniconda3\envs\my_env\python.exe
,其中my_env是您要使用的环境
Alternatively, in step 3 use C:\Miniconda3\python.exe
if you did not create any further environments (if you never invoked conda create -n my_env python=3
).
或者,在步骤 3 中使用C:\Miniconda3\python.exe
if 您没有创建任何其他环境(如果您从未调用过conda create -n my_env python=3
)。
You can get a list of your current environments with conda info -e
and switch to one of them using activate my_env
.
您可以使用 获取当前环境的列表,conda info -e
并使用 切换到其中之一activate my_env
。
回答by Lucas Roberts
It seems that each project may have a separate collection of python libraries in a project specific computing environment. To get this working with numpy
I went to the terminal at the bottom of the pycharm window and ran pip install numpy
and once the process finished running the install and indexing my python project was able to import numpy from the line of code import numpy as np
. It seems you may need to do this for each project you setup in numpy.
似乎每个项目都可能在项目特定的计算环境中拥有单独的 Python 库集合。为了让这个工作,numpy
我去了 pycharm 窗口底部的终端并运行pip install numpy
,一旦该过程完成运行安装和索引,我的 python 项目就能够从代码行导入 numpy import numpy as np
。似乎您可能需要为在 numpy 中设置的每个项目执行此操作。
回答by IsaacE
Another option is to open the terminal at the pycharm & install it with pip
另一种选择是在 pycharm 上打开终端并使用 pip 安装它
sudo pip install numpy
回答by Azriel Tan
I added Anaconda3/Library/Bin
to the environment path and PyCharm no longer complained with the error.
我添加Anaconda3/Library/Bin
到环境路径和 PyCharm 不再抱怨错误。
Stated by https://intellij-support.jetbrains.com/hc/en-us/community/posts/360001194720/comments/360000341500
由https://intellij-support.jetbrains.com/hc/en-us/community/posts/360001194720/comments/360000341500陈述