How to solve "bad interpreter: too many levels of symbolic links"

I am trying to install numpy in a virtual environment that I have created. I used the following series of commands to build and activate and then install the local version of numpy (all after cd-ing to the project folder).

virtualenv venv
source venv/bin/activate
pip install numpy

      

However, after the last command, I get this error:

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

      

Can anyone help me solve this problem and let me know what might be wrong?

I am using Ubuntu 14.04 in VirtualBox and python version is 2.7.6.

+7


source to share


6 answers


I had the same problem and decided to just delete the old env file with rm -rf env

. Then I created a new environment with virtualenv env

and then installed the requirements, usually pip install -r requirements.txt

after which I was able to successfully run my application.



+11


source


You may have python running in some other terminal instance. Remember to close all additional terminal instances



+1


source


When I tried to install Tensorflow over Virtualenv I ran into this question too. I just removed the old env and then built the new env. It works.

When I do /Users/xiang/tensorflow/bin/pip

which pip

, it returns /Users/xiang/tensorflow/bin/pip

. This is exactly the path in the new env that I built.

+1


source


This error occurs because you are starting a new process, in my case the virtual environment for the django project gets one copy and when they become for many you get this error. Just remove the old env and create a new environment.

0


source


I can vaguely suggest that the reason for this is because you have a virtualenv pointing to itself. I can vaguely imagine this will happen if you try to create a virtualenv, but then somehow decide to do it again without starting deactivate

. Then you have python

in virtualenv returning back ... python

to (effectively) the same virtualenv with a symlink.

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

Anyway, if that's the case, the other answers here say that removing env and start over is mostly correct, but remember first deactivate

.

0


source


I had it. In my case, I'm not sure what happened, but my python2 was replaced with a link, so I had:

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

      

The middle link is wrong, it is a backlink, it must be an executable file (it already had a different venv). I removed python2 and copied the actual file (in my case /bin/python2.7) there:

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

      

(NOTE: I cannot speak for every distribution, you will need to develop your own version. Try this:

ls -l 'which python'

      

and if it's a link, follow it until you get to the actual executable. For me, it was / bin / python -> python2 -> python2.7. Ergo I copied /bin/python2.7)

0


source







All Articles