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

2022-01-10 00:00:00 python numpy macos anaconda installation

问题描述

我是 Python 的新手,想用它进行数据分析.我刚刚在运行 OSX 10.8 的 Mac 上安装了 Python 2.7.我需要 NumPy、SciPy、matplotlib 和 csv 包.我读到我可以简单地安装 Anaconda 包并将所有内容合二为一.所以我继续下载/安装 Anaconda 1.7.

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.

但是,当我输入:将 numpy 导入为 np

However, when I type in: import numpy as np

我收到一条错误消息,告诉我没有这样的模块.我认为这与安装位置有关,但我不知道如何:A. 检查一切是否实际安装正确B. 检查安装位置.

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.

任何指针将不胜感激!

谢谢


解决方案

你可以通过在命令行中查看which python的结果来判断你运行的python是哪个版本的错误.很可能您正在运行系统版本(尽管最新版本的 Mac OS X 在其系统 python 中包含 numpy),而不是 Anaconda 的 python 发行版.如果是这种情况,您需要在安装过程结束时按照 Anaconda 的建议修改您的 PATH.假设它安装在 ~/anaconda 中,您需要添加如下内容:

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:

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

到你的 .bash_profile

相关文章