Python 如何检查 anaconda 包是否已正确安装
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/19029333/
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
How to check that the anaconda package was properly installed
提问by marc
I'm completely new to Python and want to use it for data analysis. I just installed Python 2.7 on my mac running OSX 10.8. I need the NumPy, SciPy, matplotlib and csv packages. I read that I could simply install the Anaconda package and get all in one. So I went ahead and downloaded/installed Anaconda 1.7.
我对 Python 完全陌生,想用它进行数据分析。我刚刚在运行 OSX 10.8 的 Mac 上安装了 Python 2.7。我需要 NumPy、SciPy、matplotlib 和 csv 包。我读到我可以简单地安装 Anaconda 包并将所有功能合而为一。所以我继续下载/安装了 Anaconda 1.7。
However, when I type in: import numpy as np
但是,当我输入: import numpy as np
I get an error telling me that there is no such module. I assume this has to do with the location of the installation, but I can't figure out how to: A. Check that everything is actually installed properly B. Check the location of the installation.
我收到一个错误,告诉我没有这样的模块。我认为这与安装位置有关,但我不知道如何: A. 检查所有内容是否实际安装正确 B. 检查安装位置。
Any pointers would be greatly appreciated!
任何指针将不胜感激!
Thanks
谢谢
采纳答案by JoshAdel
You can determine which version of python you are running when you get the error by looking at the results of which python
from the commandline. It is likely that you are running the system version (although recent versions Mac OS X include numpy in its system python), rather than Anaconda's python distribution. If this is the case, you need to modify your PATH
as suggested by Anaconda at the end of the install process. Assuming it was installed in ~/anaconda
, you would need to add something like:
您可以通过查看which python
命令行的结果来确定在出现错误时正在运行的 Python 版本。您可能正在运行系统版本(尽管最近版本的 Mac OS X 在其系统 python 中包含 numpy),而不是 Anaconda 的 python 发行版。如果是这种情况,您需要PATH
在安装过程结束时按照 Anaconda 的建议进行修改。假设它安装在 中~/anaconda
,您需要添加如下内容:
export PATH=$HOME/anaconda/bin:$PATH
to your .bash_profile
给你的 .bash_profile
回答by Dhruv Ghulati
I don't think the existing answer answers your specific question (about installing packages within Anaconda). When I install a new package via conda install <PACKAGE>
, I then run conda list
to ensure the package is now within my list of Anaconda packages.
我认为现有答案不能回答您的具体问题(关于在 Anaconda 中安装软件包)。当我通过 安装新软件包时conda install <PACKAGE>
,我会运行conda list
以确保该软件包现在在我的 Anaconda 软件包列表中。
回答by Upendra Bittu
Though the question is not relevant to Windows environment, FYI for windows. In order to use anaconda modules outside spyder or in cmd prompt, try to update the PYTHONPATH & PATH with C:\Users\username\Anaconda3\lib\site-packages.
尽管该问题与 Windows 环境无关,但仅供 Windows 参考。为了在 spyder 之外或在 cmd 提示符下使用 anaconda 模块,请尝试使用 C:\Users\username\Anaconda3\lib\site-packages 更新 PYTHONPATH 和 PATH。
Finally, restart the command prompt.
最后,重新启动命令提示符。
Additionally, sublime has a plugin 'anaconda' which can be used for sublime to work with anaconda modules.
此外,sublime 有一个插件“anaconda”,可用于 sublime 与 anaconda 模块一起工作。
回答by Akash Kandpal
you might want to try this:
你可能想试试这个:
for anaconda 2 :
对于蟒蛇2:
export PATH=~/anaconda2/bin:$PATH
for anaconda 3 :
对于蟒蛇3:
export PATH=~/anaconda3/bin:$PATH
for anaconda 4 :
对于蟒蛇 4 :
Use the Anaconda Prompt
使用 Anaconda 提示
and then
进而
conda --version
to confirm that it worked.
以确认它有效。