how to solve “bad interpreter: Too many levels of symbolic links”

前端 未结 6 1914
野趣味
野趣味 2020-12-09 20:25

I am trying to install numpy in a virtual environment that I created. I used the following series of commands to create and activate and then installing a local version of n

相关标签:
6条回答
  • 2020-12-09 20:47

    When I tried to install Tensorflow by Virtualenv, I confronted this question too. I just removed the old env, then built a new env. It works.

    When I type which pip, it returns /Users/xiang/tensorflow/bin/pip. Which is exactly the path in the new env I built.

    0 讨论(0)
  • 2020-12-09 20:49

    I had the same issue, and solved it simply by removing the old env file with rm -rf env. Then I created a new environment with virtualenv env, followed by installing the requirements, normally pip install -r requirements.txt, then I was able to run my app successfully.

    0 讨论(0)
  • 2020-12-09 20:50

    You may have python running in some other instance of terminal. Make sure to close all additional instances of terminals

    0 讨论(0)
  • 2020-12-09 20:56

    I had this. In my case I am not sure what happened but my python2 had been replaced by 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, this is a circual reference, it should be the executable (had another venv to look at already). I deleted python2 and copied the actual file (in my case /bin/python2.7) to 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 can't speak for every distro. you'll need to work out your own version. Try this:

    ls -l `which python`
    

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

    0 讨论(0)
  • 2020-12-09 21:03

    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.

    0 讨论(0)
  • 2020-12-09 21:04

    This error is occurs 'cause time you start a new process, in my case virtual environment for django project one copy is made and when they becomes to many you get this error. Just remove the old env and create a new environment.

    0 讨论(0)
提交回复
热议问题