简体   繁体   English

如何检查anaconda包是否已正确安装

[英]How to check that the anaconda package was properly installed

I'm completely new to Python and want to use it for data analysis. 我是Python的新手,想用它来进行数据分析。 I just installed Python 2.7 on my mac running OSX 10.8. 我刚刚在运行OSX 10.8的mac上安装了Python 2.7。 I need the NumPy, SciPy, matplotlib and csv packages. 我需要NumPy,SciPy,matplotlib和csv包。 I read that I could simply install the Anaconda package and get all in one. 我读到我可以简单地安装Anaconda软件包并将其全部集成在一起。 So I went ahead and downloaded/installed Anaconda 1.7. 所以我继续下载/安装了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 谢谢

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. 通过查看命令行中which python的结果,您可以确定在获取错误时正在运行的python版本。 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. 您可能正在运行系统版本(尽管最新版本Mac OS X在其系统python中包含numpy),而不是Anaconda的python发行版。 If this is the case, you need to modify your PATH as suggested by Anaconda at the end of the install process. 如果是这种情况,则需要在安装过程结束时按照Anaconda的建议修改PATH Assuming it was installed in ~/anaconda , you would need to add something like: 假设它安装在~/anaconda ,您需要添加如下内容:

export PATH=$HOME/anaconda/bin:$PATH

to your .bash_profile 你的.bash_profile

Though the question is not relevant to Windows environment, FYI for windows. 虽然这个问题与Windows环境无关,但是对于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. 要在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',可用于升级以与anaconda模块一起使用。

I don't think the existing answer answers your specific question (about installing packages within Anaconda). 我不认为现有的答案会回答您的具体问题(关于在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. 当我通过conda install <PACKAGE>安装新软件包时,我运行conda list以确保软件包现在在我的Anaconda软件包列表中。

you might want to try this: 你可能想试试这个:

for anaconda 2 : 为anaconda 2:

export PATH=~/anaconda2/bin:$PATH

for anaconda 3 : 对于anaconda 3:

export PATH=~/anaconda3/bin:$PATH

for anaconda 4 : 对于anaconda 4:

Use the Anaconda Prompt 使用Anaconda提示

and then 接着

conda --version

to confirm that it worked. 确认它有效。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM