多年来,我的Mac上已经安装了很多Python和Anacondas,并且在某种程度上这些已被忽略,我怀疑现在重新出现并引起我的问题。
我想设置 virtualenv 环境并执行 pip install virtualenv 。我想为Django1.8创建一个新的环境 Django18 ,但在执行命令 virtualenv Django18 后,我收到一条错误消息:
OSError: Command ~/Desktop/Django18/bin/python - setuptools pip wheel failed with error code 1
的.bash_profile
# added by Anaconda2 4.2.0 installer
export PATH="~/anaconda2/bin:$PATH"
命令:哪个python
~/anaconda2/bin/python
在/ usr / bin /:
-rwxr-xr-x 2 root wheel 58416 Jul 15 2015 python
-rwxr-xr-x 5 root wheel 925 Sep 10 2014 python-config
lrwxr-xr-x 1 root wheel 75 Nov 9 2014 python2.6 -> ../../System/Library/Frameworks/Python.framework/Versions/2.6/bin/python2.6
lrwxr-xr-x 1 root wheel 82 Nov 9 2014 python2.6-config -> ../../System/Library/Frameworks/Python.framework/Versions/2.6/bin/python2.6-config
lrwxr-xr-x 1 root wheel 75 Nov 9 2014 python2.7 -> ../../System/Library/Frameworks/Python.framework/Versions/2.7/bin/python2.7
lrwxr-xr-x 1 root wheel 82 Nov 9 2014 python2.7-config -> ../../System/Library/Frameworks/Python.framework/Versions/2.7/bin/python2.7-config
-rwxr-xr-x 2 root wheel 58416 Jul 15 2015 pythonw
lrwxr-xr-x 1 root wheel 76 Nov 9 2014 pythonw2.6 -> ../../System/Library/Frameworks/Python.framework/Versions/2.6/bin/pythonw2.6
lrwxr-xr-x 1 root wheel 76 Nov 9 2014 pythonw2.7 -> ../../System/Library/Frameworks/Python.framework/Versions/2.7/bin/pythonw2.7
的.profile
export PATH="/opt/local/lib/gmt4/bin:$PATH"
export PATH="~/teqc:$PATH"
export PATH="/usr/local/runpkr000:$PATH"
export LC_ALL=en_US.UTF-8
export LANG=en_US.UTF-8
# MacPorts Installer addition on 2015-04-02_at_16:40:23: adding an appropriate PATH variable for use with MacPorts.
# export PATH="/opt/local/bin:/opt/local/sbin:$PATH"
# Finished adapting your PATH environment variable for use with MacPorts.
# added by Anaconda 2.3.0 installer
# export PATH="~/anaconda/bin:$PATH"
我怀疑需要对此进行一些清理,但是如何解决此错误消息并让 virtualenv 按预期工作?我已经尝试了几种方法,但在应用潜在的补救措施之前,我很难理解在我的案例中究竟是什么导致了这个问题。
/ opt / local / bin(是macports安装)?:
lrwxr-xr-x 1 root admin 24 Oct 9 2016 python -> /opt/local/bin/python2.7
lrwxr-xr-x 1 root admin 31 Oct 9 2016 python-config -> /opt/local/bin/python2.7-config
lrwxr-xr-x 1 root admin 73 Dec 14 2014 python2.7 -> /opt/local/Library/Frameworks/Python.framework/Versions/2.7/bin/python2.7
lrwxr-xr-x 1 root admin 80 Dec 14 2014 python2.7-config -> /opt/local/Library/Frameworks/Python.framework/Versions/2.7/bin/python2.7-config
lrwxr-xr-x 1 root admin 25 Oct 9 2016 pythonw -> /opt/local/bin/pythonw2.7
lrwxr-xr-x 1 root admin 74 Dec 14 2014 pythonw2.7 -> /opt/local/Library/Frameworks/Python.framework/Versions/2.7/bin/pythonw2.7
的/ usr /本地/ bin中
lrwxr-xr-x 1 root staff 69 Dec 12 2012 python3 -> ../../../Library/Frameworks/Python.framework/Versions/3.3/bin/python3
lrwxr-xr-x 1 root staff 72 Dec 12 2012 python3-32 -> ../../../Library/Frameworks/Python.framework/Versions/3.3/bin/python3-32
lrwxr-xr-x 1 root staff 76 Dec 12 2012 python3-config -> ../../../Library/Frameworks/Python.framework/Versions/3.3/bin/python3-config
lrwxr-xr-x 1 root staff 71 Dec 12 2012 python3.3 -> ../../../Library/Frameworks/Python.framework/Versions/3.3/bin/python3.3
lrwxr-xr-x 1 root staff 74 Dec 12 2012 python3.3-32 -> ../../../Library/Frameworks/Python.framework/Versions/3.3/bin/python3.3-32
lrwxr-xr-x 1 root staff 78 Dec 12 2012 python3.3-config -> ../../../Library/Frameworks/Python.framework/Versions/3.3/bin/python3.3-config
lrwxr-xr-x 1 root staff 72 Dec 12 2012 python3.3m -> ../../../Library/Frameworks/Python.framework/Versions/3.3/bin/python3.3m
lrwxr-xr-x 1 root staff 79 Dec 12 2012 python3.3m-config -> ../../../Library/Frameworks/Python.framework/Versions/3.3/bin/python3.3m-config
lrwxr-xr-x 1 root staff 70 Dec 12 2012 pythonw3 -> ../../../Library/Frameworks/Python.framework/Versions/3.3/bin/pythonw3
lrwxr-xr-x 1 root staff 73 Dec 12 2012 pythonw3-32 -> ../../../Library/Frameworks/Python.framework/Versions/3.3/bin/pythonw3-32
lrwxr-xr-x 1 root staff 72 Dec 12 2012 pythonw3.3 -> ../../../Library/Frameworks/Python.framework/Versions/3.3/bin/pythonw3.3
lrwxr-xr-x 1 root staff 75 Dec 12 2012 pythonw3.3-32 -> ../../../Library/Frameworks/Python.framework/Versions/3.3/bin/pythonw3.3-32
导入系统 sys.path中
~/anaconda2/lib/python27.zip
~/anaconda2/lib/python2.7
~/anaconda2/lib/python2.7/plat-darwin
~/anaconda2/lib/python2.7/plat-mac
~/anaconda2/lib/python2.7/plat-mac/lib-scriptpackages
~/anaconda2/lib/python2.7/lib-tk
~/anaconda2/lib/python2.7/lib-old
~/anaconda2/lib/python2.7/lib-dynload
~/anaconda2/lib/python2.7/site-packages
~/anaconda2/lib/python2.7/site-packages/Sphinx-1.4.6-py2.7.egg
~/anaconda2/lib/python2.7/site-packages/aeosa
~/anaconda2/lib/python2.7/site-packages/setuptools-27.2.0-py2.7.egg
的/ opt /本地/库/框架:
Python.framework
/系统/库/框架
Python.framework
修改
which python
产生:
~/anaconda2/bin/python
which -a python
产生:
~/anaconda2/bin/python
/usr/bin/python
他们不一样。但是在删除python安装之后:
/opt/local/bin
/usr/Local/bin
/usr/bin
并在
中使用rm -rf python*
和sudo rm -rf python*
/opt/local/Library/Frameworks
which
输出变得相同。
我已经意识到which python
命令实际上指的是.bash_profile
文件中写的内容而不是.profile
(优先级为.bash_profile)。
在任何情况下,我都在$PATH
中注释了.bash_profile
,因此强制环境变量仅用于.profile
文件。然后是source ~/.bash_profile
。
在.profile
我添加了:
export PATH="/Library/Frameworks/Python.framework/Versions/3.3/lib/python3.3/site-packages:$PATH
然后source ~/.profile
然而,which python
之后我还是得到了:
~/anaconda2/bin/python
这有点令人沮丧,因为即使更改相关文件和删除某些python安装,结果仍然相同: - /
答案 0 :(得分:1)
对我来说,最好的解决方法是首先检查which -a python
,在我的情况下有两次出现:
~/anaconda2/bin/python
/usr/bin/python
由于某些未知原因,virtualenv
命令似乎不喜欢安装python的anaconda,所以请改用:
virtualenv -p /usr/bin/python2.7 my_environment
答案 1 :(得分:1)
我遇到了同样的错误,但后来我才意识到我试图在与我的Python安装文件夹(C)相同的目录级别下创建一个virtualenv文件夹(C:/ myname / virtual_folder)。 :/ myname / python27)。
所以我只创建了一个文件夹,然后在其中(C:/ myname / newfolder / ..)里面运行了(“ virtualenv virtual_folder”),没有问题。
答案 2 :(得分:0)
如果你有几个不同的python和anaconda安装,我唯一能推荐的就是清理。但也对其他人会说的感兴趣。