我在macbook air上运行OSX Yosemite。我安装了python3,以及apple开发包。我正在尝试安装已安装的模块,包括matplotlib。基本上当我尝试安装SciPy,Ginga,AstroPy,iPython等科学python软件包时,我在尝试安装pip后在终端中得到了这个:
-bash: pip: command not found
所以我尝试下载tarball(如果提供),并按照说明按照网站和README文件的指示安装,我仍然会收到错误。例如,在这个astropy tarball中,它声明从目录运行python setup.py install,这就是:
jesses-Air:astropy-1.0 jessehanowell$ python setup.py install
running install
Checking .pth file support in /Library/Python/2.7/site-packages/
error: can't create or remove files in install directory
The following error occurred while trying to add or remove files in the
installation directory:
[Errno 13] Permission denied: '/Library/Python/2.7/site-packages/test-easy-
install-632.pth'
The installation directory you specified (via --install-dir, --prefix, or
the distutils default setting) was:
/Library/Python/2.7/site-packages/
Perhaps your account does not have write access to this directory? If the
installation directory is a system-owned directory, you may need to sign in
as the administrator or "root" account. If you do not have administrative
access to this machine, you may wish to choose a different installation
directory, preferably one that is listed in your PYTHONPATH environment
variable.
For information on other options, you may wish to consult the
documentation at:
https://pythonhosted.org/setuptools/easy_install.html
Please make the appropriate changes for your system and try again.
它说" python3 setup.py install"命令也是。请记住,我安装了python3,Yosemite仍在python v2.4.7上运行,我从下载目录运行终端,文件所在的位置。也许我必须将文件解压缩文件更改为新位置?但基本上我很失望,因为我真的想学习使用这些包。我知道如果我的朋友能够安装matplotlib,我应该能够安装它们。
那么有没有办法将pip恢复到我的电脑并以这种方式安装?或者有人能指出我做错的显而易见的事情吗?谢谢你的帮助!
答案 0 :(得分:3)
对于阅读其他一些回复的人,我应该强调你应该不使用sudo
来绕过权限错误 - 而是运行install命令:
python setup.py install --user
这会将软件包安装到您主目录中的Library
。
一般情况下,我实际上建议使用Anaconda Python Distribution在Mac上安装Scientific Python发行版(默认包括Numpy,SciPy,Astropy等)。
答案 1 :(得分:-1)
权限被拒绝的问题通常意味着您需要在命令前添加sudo。
这是我做过的一篇文章,包括用自制软件安装python:
https://rlkamradt.wordpress.com/2015/02/14/setting-up-a-development-environment-on-a-mac-languages/