python virtualenv 坑,python virtualenv的许多问题

I've been having a lot of trouble with getting virtualenv to work.

First I installed it via pip and then tried setting up a virtualenv. That didn't work and I got this error message:

ResNets-iMac:desktop zachary$ virtualenv anothertest

Using base prefix '/Applications/Canopy.app/appdata/canopy-1.5.1.2730.macosx-x86_64/Canopy.app/Contents'

New python executable in anothertest/bin/python

dyld: Library not loaded: @rpath/Python

Referenced from: /Users/zachary/Desktop/anothertest/bin/python

Reason: image not found

ERROR: The executable anothertest/bin/python is not functioning

ERROR: It thinks sys.prefix is u'/Users/zachary/Desktop' (should be u'/Users/zachary/Desktop/anothertest')

ERROR: virtualenv is not compatible with this system or executable

So then I went through just about all of the troubleshooting I could and decided that Canopy was the problem. So I deleted that, reinstalled virualenv (via 'pip uninstall virtualenv' then 'pip install virtualenv') and now I am getting this error whenever I try to do anything involving virtualenv:

dyld: Library not loaded: @rpath/Python

Referenced from: /Users/zachary/Library/Enthought/Canopy_64bit/User/bin/python

Reason: image not found

I'm not sure what to do and when I check what my default version of python is, I get:

/Library/Frameworks/Python.framework/Versions/2.7/bin/python

I very new at all of this and I don't really have any idea what I have been doing or how to fix this so any help would be greatly appreciated.

Thanks!

解决方案

The problem is you have multiple versions of Python on your system.

You have the Python that ships with OSX (/Library/Frameworks/Python.framework/Versions/2.7/bin/python), then you have the Python that comes with Canopy; which is /Users/zachary/Library/Enthought/Canopy_64bit/User/bin/python.

Your path is pointing the default version to the one from Canopy, yet pip is installed against the default system version of Python.

So when you installed virtualenv, it was installed against the default version of Python; but when you try to create a virtual environment - due to the way your path are setup, it is trying to use the Canopy version of Python - and that's the source of your error.

To solve this problem you can do any of the following:

Remove Canopy, and use the OSX version of Python.

Install virtualenv on the Canopy version of Python.

Modify your PATH so that the system version of Python takes precedence.

Install another version of Python (from say, homebrew) and make that the default.

The resolution you chose will depend on what you need the system to do. If you need the libraries bundled with Canopy, then you need to choose option #2, otherwise pick any of the other options. #4 is the most disruptive (as it will involve installing a lot of other stuff).

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值