如何解决"糟糕的翻译:太多级别的符号链接"

时间:2015-07-29 09:13:57

标签: python linux virtualenv

我正在尝试在我创建的虚拟环境中安装numpy。我使用以下一系列命令来创建和激活然后安装本地版本的numpy(所有这些在进入项目文件夹之后)。

virtualenv venv
source venv/bin/activate
pip install numpy

然而,在最后一个命令之后,我收到了这个错误:

bash: /home/fieldsofgold/Desktop/test/venv/bin/pip: /home/fieldsofgold/Desktop/test/venv/bin/python: bad interpreter: Too many levels of symbolic links

有人可以帮我解决一下,让我知道会出现什么问题吗?

我在VirtualBox中使用Ubuntu 14.04,python版本是2.7.6。

6 个答案:

答案 0 :(得分:13)

我遇到了同样的问题,只需使用rm -rf env删除旧的env文件即可解决问题。然后我使用virtualenv env创建了一个新环境,然后安装了需求,通常是pip install -r requirements.txt,然后我就能成功运行我的应用。

答案 1 :(得分:1)

您可能在其他终端实例中运行python。确保关闭所有其他终端实例

答案 2 :(得分:1)

当我尝试通过Virtualenv安装Tensorflow时,我也遇到了这个问题。我只是删除了旧的环境,然后构建了一个新的环境。有用。

当我键入which pip时,它将返回/Users/xiang/tensorflow/bin/pip。这正是我构建的新环境中的路径。

答案 3 :(得分:0)

发生此错误'导致您开始新进程的时间,在我的情况下,django项目的虚拟环境会生成一个副本,当它们变为多个时,您会收到此错误。 只需删除旧环境并创建一个新环境。

答案 4 :(得分:0)

I can vaguely speculate that the reason for this is that you have a virtualenv pointing to itself. I can further vaguely speculate that this would happen if you attempt to create a virtualenv, but then somehow decide to do it again without running deactivate. Then you have python in the virtualenv pointing back to ... python in (effectively) the same virtualenv by a symbolic link.

Since this is speculative, I hope someone who actually has this problem can confirm or deny that this is what happened.

Anyway, if this is the case, the other answers here saying remove the env and start over are basically correct, but remember to deactivate first.

答案 5 :(得分:0)

我有这个。就我而言,我不确定发生了什么,但是我的python2已被链接替换,所以我有:

ls -l
lrwxrwxrwx 1 <me> staff    7 Oct 23 14:04 python -> python2
lrwxrwxrwx 1 <me> staff    6 Nov  6 14:28 python2 -> python
lrwxrwxrwx 1 <me> staff    7 Oct 23 14:04 python2.7 -> python2

中间链接是错误的,这是一个循环引用,它应该是可执行文件(已经有另一个venv查看了)。我删除了python2并将实际文件(以我的情况为/bin/python2.7)复制到了该位置:

rm python2
cp /bin/python2.7 python2
ls -l
lrwxrwxrwx 1 <me> staff    7 Oct 23 14:04 python -> python2
-rwxr-xr-x 1 <me> staff 7216 Dec  6 14:57 python2
lrwxrwxrwx 1 <me> staff    7 Oct 23 14:04 python2.7 -> python2

(注意:我不能为每个发行版说话。您需要制定自己的版本。请尝试以下操作:

ls -l `which python`

,如果是链接,请跟随它,直到获得实际的可执行文件为止。对我来说是/ bin / python-> python2-> python2.7。因此,我复制了/bin/python2.7)