mkvirtualenv: Too many levels of symbolic links

2020-02-26 15:05发布

问题:

I am running virtualenv burrito and getting an error that there are too many levels of symbolic links. I have no idea what that means.

mkvirtualenv --python /usr/local/bin/Python3 mantis

Error:

Running virtualenv with interpreter /usr/local/bin/Python3
Using base prefix '/Library/Frameworks/Python.framework/Versions/3.4'
New python executable in mantis/bin/Python3
Also creating executable in mantis/bin/python
Traceback (most recent call last):
  File "/Users/croberts/.venvburrito/lib/python2.7/site-packages/virtualenv.py", line 2352, in <module>
    main()
  File "/Users/croberts/.venvburrito/lib/python2.7/site-packages/virtualenv.py", line 825, in main
    symlink=options.symlink)
  File "/Users/croberts/.venvburrito/lib/python2.7/site-packages/virtualenv.py", line 985, in create_environment
    site_packages=site_packages, clear=clear, symlink=symlink))
  File "/Users/croberts/.venvburrito/lib/python2.7/site-packages/virtualenv.py", line 1439, in install_python
    raise e
  File "/Users/croberts/.venvburrito/lib/python2.7/site-packages/virtualenv.py", line 1431, in install_python
    stdout=subprocess.PIPE)
  File "/Library/Frameworks/Python.framework/Versions/3.4/lib/python3.4/subprocess.py", line 859, in __init__
    restore_signals, start_new_session)
  File "/Library/Frameworks/Python.framework/Versions/3.4/lib/python3.4/subprocess.py", line 1457, in _execute_child
    raise child_exception_type(errno_num, err_msg)
OSError: [Errno 62] Too many levels of symbolic links

I was getting this error before and solved it by doing Python3.4 instead of Python3. Now it won't work no matter which python I try to use. Even if I try to use the default (2.7)

回答1:

Strangely, I ran into this when I tried to create a virtualenv with a name that already existed. Solution to remove the old and create a new one:

rmvirtualenv old-one
mkvirtualenv new-one


回答2:

I had the same problem on OSX.

I got rid of it after:

1. removing env folder
2. removing __pycache__ folder


回答3:

The reason this wasn't working was because I was capitalizing Python. As soon as I did it using python3 instead of Python3 I stopped getting trouble.



回答4:

I'm using a mac and I solved this by rm the virtual env that is named the same as you are trying to create. Specifically, I rm the folder within Users/user_name/.virtualenvs/. Then the create worked.



回答5:

I came across it after I had built my freshest environment. Because it has been interrupted by myself while it was building the new one. Then I noticed that virtualenvwrapper already created a new environment folder underneath the environment directory but it has not been accomplished properly. Hence, I deleted the lastest environment folder and retried to install same environment. It fixed!



回答6:

I had the same problem in raspberry pi during open cv installation. I solve my problem by using below method.

Go to /home/pi ls -all and check weather .virtualenvs is there or not if it is there remove it by rm -r .virtualenvs



回答7:

I'm not sure why but using

python3 -m venv venv

instead of

virtualenv -p python3 venv

and then activating the venv or setting the paths manually, something like this

      export PYTHONPATH=.:\$PYTHONPATH
      VIRTUAL_ENV=`pwd`/venv
      export VIRTUAL_ENV
      PATH="\$VIRTUAL_ENV/bin:\$PATH"
      export PATH

worked for me.

I tried to do some quick searching of the different between virtualenv and python3 -m venv module...but didn't find anything.



回答8:

File "/Users/croberts/? seems you're using Windows. Consider using 'virtualenvwrapper-win'. The latest version is 1.2.0 which support python 2 up to 3.4. I've used it without any problems. If you use several versions of python on your computer, you can switch between them using 'pywin'.

For making new virtualenv:

C:\Users\your_directory>mkvirtualenv neo
Using base prefix 'C:\\Python34'
New python executable in neo\Scripts\python.exe
Installing setuptools, pip...done.

For view existing virtualenv:

C:\Users\your_directory>lsvirtualenv

dir /b /ad "C:\Users\your_directory"
=========================================================================
env0
env1
env2
neo