python virtualenv的许多问题 [英] Many Problems with python's virtualenv

查看:88
本文介绍了python virtualenv的许多问题的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在使virtualenv正常工作方面我遇到了很多麻烦.

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

首先,我通过pip安装了它,然后尝试设置virtualenv.那没有用,我得到了这个错误信息:

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

因此,我几乎完成了所有可能的故障排除,并确定Canopy是问题所在.所以我删除了它,重新安装了virualenv(通过"pip install virtualenv"然后"pip install virtualenv"),现在,当我尝试执行任何涉及virtualenv的操作时,都会出现此错误:

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

我不确定该怎么做,当我检查python的默认版本是什么时,我得到:

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.

谢谢!

推荐答案

问题是您的系统上有多个Python版本.

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

您有OSX(/Library/Frameworks/Python.framework/Versions/2.7/bin/python)附带的Python,然后有Canopy附带的Python;是/Users/zachary/Library/Enthought/Canopy_64bit/User/bin/python.

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.

您的路径将默认版本指向Canopy的版本,但是pip已针对Python的默认系统版本安装.

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

因此,当您安装virtualenv时,它是根据Python的默认版本安装的;但是,当您尝试创建虚拟环境时(由于设置路径的方式,它正尝试使用Canopy版本的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:

  1. 删除机盖,并使用OSX版本的Python.
  2. 在Python的Canopy版本上安装virtualenv.
  3. 修改您的PATH,以使Python的系统版本优先.
  4. 安装另一个版本的Python(例如自制软件),并将其设置为默认版本.

您选择的分辨率将取决于系统需要执行的操作.如果需要与Canopy捆绑在一起的库,则需要选择选项#2,否则请选择其他任何选项. #4是最具破坏性的(因为这将涉及安装许多其他东西).

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).

这篇关于python virtualenv的许多问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆