我使用的是 mac OSX,并且已经通过以下方式安装了 python 2.7.9本文,
如果我在 bash 终端中/usr/bin
运行命令,我得到ls -l /usr/bin/python*
lrwxr-xr-x 1 root wheel 67 Jan 24 02:12 /usr/bin/python -> /System/Library/Frameworks/Python.framework/Versions/2.7/bin/python
lrwxr-xr-x 1 root wheel 74 Jan 24 02:12 /usr/bin/python-config -> /System/Library/Frameworks/Python.framework/Versions/2.7/bin/python-config
lrwxr-xr-x 1 root wheel 75 Oct 19 16:39 /usr/bin/python2.6 -> ../../System/Library/Frameworks/Python.framework/Versions/2.6/bin/python2.6
lrwxr-xr-x 1 root wheel 82 Oct 19 16:39 /usr/bin/python2.6-config -> ../../System/Library/Frameworks/Python.framework/Versions/2.6/bin/python2.6-config
lrwxr-xr-x 1 root wheel 75 Oct 19 16:39 /usr/bin/python2.7 -> ../../System/Library/Frameworks/Python.framework/Versions/2.7/bin/python2.7
lrwxr-xr-x 1 root wheel 82 Oct 19 16:39 /usr/bin/python2.7-config -> ../../System/Library/Frameworks/Python.framework/Versions/2.7/bin/python2.7-config
lrwxr-xr-x 1 root wheel 68 Jan 24 02:12 /usr/bin/pythonw -> /System/Library/Frameworks/Python.framework/Versions/2.7/bin/pythonw
lrwxr-xr-x 1 root wheel 76 Oct 19 16:39 /usr/bin/pythonw2.6 -> ../../System/Library/Frameworks/Python.framework/Versions/2.6/bin/pythonw2.6
lrwxr-xr-x 1 root wheel 76 Oct 19 16:39 /usr/bin/pythonw2.7 -> ../../System/Library/Frameworks/Python.framework/Versions/2.7/bin/pythonw2.7
如果我跑ls -l | grep easy_install
,我会得到
-rwxr-xr-x 2 root wheel 925 Sep 9 19:31 easy_install
-rwxr-xr-x 1 root wheel 454 Sep 9 19:31 easy_install-2.6
-rwxr-xr-x 1 root wheel 461 Sep 9 19:31 easy_install-2.7
当我查看这 3 个文件的内容时,它们分别是
#!/usr/bin/python
#!/System/Library/Frameworks/Python.framework/Versions/2.6/Resources/Python.app/Contents/MacOS/Python
#!/System/Library/Frameworks/Python.framework/Versions/2.7/Resources/Python.app/Contents/MacOS/Python
我尝试过修改写入权限,这样我就可以自己进入并更改路径,但当我这样做时,IDE 中仍然会发出警告,说我没有写入权限。我还觉得,如果我没有正确配置这些文件,我可能会弄乱这些文件,从而损害我的系统。有人能告诉我如何设置 easy install,以便在运行类似这样的命令时它能正常工作吗sudo easy_install six
?现在,当我运行这个命令时,它告诉我
unable to execute /System/Library/Frameworks/Python.framework/Versions/2.7/bin/easy_install: No such file or directory
我已经进入该目录并将easy_install2.7
其中的文件更改为简单的easy_install
,但仍然出现相同的错误。我还尝试将文件easy_install
从 /usr/bin 复制到该位置,但没有成功:
python version 2.7.9 can't run /System/Library/Frameworks/Python.framework/Versions/2.7/bin/easy_install. Try the alternative(s):
/System/Library/Frameworks/Python.framework/Versions/2.7/bin/easy_install (uses python 2.7)
/System/Library/Frameworks/Python.framework/Versions/2.7/bin/easy_install-2.7 (uses python 2.7)
我已经将所有文件恢复为原始名称,并/usr/bin
从 2.7 目录中删除了 easy_install 版本。有人能帮我吗?
其他重要信息:
答案1
Homebrew 或 python.org python 安装都不会改变系统目录中的任何内容。
它们都将 python 放入 /usr/local/bin,并且这应该位于 /usr/bin 之前的路径上,以允许您从命令行运行 python。
应该使用这个 python 安装 easy_install,并将 easy_install 放入 /usr/local.bin 中,并带有正确的标头。
答案2
我有同样的问题:
Dhruv’s MacBook Pro:~ dhruv$ sudo easy_install pip
Password:
sudo: unable to execute /System/Library/Frameworks/Python.framework/Versions/2.7/bin/easy_install: No such file or directory
我遵循了提到的相同教程。如果您说的是这个,我该如何使用特定目录中的 python?