mkvirtualenv: Too many levels of symbolic links - virtualenv

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)

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

I had the same problem on OSX.
I got rid of it after:
1. removing env folder
2. removing __pycache__ folder

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.

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.

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.

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!

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

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

Related

What is the difference between running a vscode command in the shell and the command which is shown in the output?

I am running test discovery in vscode with pytest in the output shows me this command:
python /home/dave/.vscode/extensions/ms-python.python-2020.6.88468/pythonFiles/testing_tools/run_adapter.py discover pytest -- --rootdir /home/dave/PythonProjects/pytest_test -s --cache-clear .
Executing this command in the vscode shell leads to an import error.
dave#dave-desktop  ~/PythonProjects/pytest_test   master  python /home/dave/.vscode/extensions/ms-python.python-2020.6.88468/pythonFiles/testing_tools/run_adapter.py discover pytest -- --rootdir /home/dave/PythonProjects/pytest_test -s --cache-clear .
Traceback (most recent call last):
File "/home/dave/.vscode/extensions/ms-python.python-2020.6.88468/pythonFiles/testing_tools/run_adapter.py", line 17, in <module>
from testing_tools.adapter.__main__ import parse_args, main
File "/home/dave/.vscode/extensions/ms-python.python-2020.6.88468/pythonFiles/testing_tools/adapter/__main__.py", line 9, in <module>
from . import pytest, report
File "/home/dave/.vscode/extensions/ms-python.python-2020.6.88468/pythonFiles/testing_tools/adapter/pytest/__init__.py", line 7, in <module>
from ._discovery import discover
File "/home/dave/.vscode/extensions/ms-python.python-2020.6.88468/pythonFiles/testing_tools/adapter/pytest/_discovery.py", line 8, in <module>
import pytest
ImportError: No module named pytest
Why does this show an error? Is this command executed from another directory. This is very frustrating, because i have no chance of analysing the error this way.
You are probably actually invoking different Python interpreters/environments in each methods. VSCode docs say:
By default, the Python extension looks for and uses the first Python interpreter it finds in the system path.
But there are several ways of overriding this, manually selecting the interpreter is the most obvious.
To debug, I suggest you temporarily put the following lines at the very top of run_adapter.py (might wanna back it up first, as it is part of the VS-code Python extension):
import sys
print(f'interpreter: {sys.executable}')
This will print the path of your interpreter just before the import fails.
You might also want to take a look at this question.
I couldn't see if in the comments above you answered whether the virtual environment was activated or not. It could happen that VSCode is executing the command from a place where the python executable and the module pytest both exist.
One option would be to install pytest globally and see if that helps (you can uninstall it later to clean your system, if needed).
Otherwise, be sure to create a virtual environment, activate it and install pytest on it before running your command.
python3 -m venv /path/to/new/virtual/environment (e.g. ./venv)
./venv/bin/activate
pip3 install pytest
Also, if you have Python 2 and 3 in the same environment, that could cause conflicts. Can you check whether the correct version is used by VSCode (3 from your example, I guess)? You can do Ctrl + Shift + p and select "Python: Select Intepreter" to select the correct version.

pyrcc5: No such file or directory

I want to install labelImg for mac OS in python 3.7. here is the repo: https://github.com/tzutalin/labelImg
I have installed previous modules via 'pip3 install pyqt5 lxml' successfully. Cloned the repo, entered the folder 'labelImg', but only 'make qt5py3' does not work..
but when I execute 'make qt5py3', i get the error
pyrcc5 -o libs/resources.py resources.qrc
make: pyrcc5: No such file or directory
make: *** [qt5py3] Error 1
What can I do here? What might have caused the issue?
-find 'pyrcc5' under python bin, and copy 'path'
-under labelImg find 'Makefile' and edit
-change line
qt5py3: pyrcc5 to qt5py3: 'copied path'/pyrcc5
and save
-and
make qt5py3
python labelImg.py
should works.
I had the same issues as the OP, but with Python 3.6.11. In addition, I got ModuleNotFoundErrors for pyqt5 and libxml2, even though brew confirmed they were both installed. Also, I was trying to install in a virtual environment set up using pyenv.
What finally worked for me was:
1) use global env, not virtual
2) use pip (not pip3) to install pyqt5 and lxml
3) change the makefile as #zippo suggested
After I did that, I was able to get labelImg to start by running:
python labelImg.py

Python venv is giving errno 2 in visual studio code

I tried to make a virtual environment as stated in the documentation of the visual studio code. I have already installed python 3.7.3 and anaconda on the system.
I did the following and I'm using vs code version 1.34 and windows 10:
I made an empty folder and used this line of code as stated in official documentation:
py -3 -m venv .venv
I expected a folder named .venv that has scripts folder with 'activate' file in it. As i have tested this method which worked on other systems with the same configuration, But instead i get the below error message:
Error: [Errno 2]: no such file or directory : 'C:\\ProgramData\\Anaconda3\\lib\\venv\\scripts\\nt\\python.exe'
It look like installer is broken, or so...
Copy from Python 3 installation folder:
C:\Users{user}\AppData\Local\Programs\Python\Python37
Files: python.exe, python.pdb, python_d.exe, python_d.pdb, pythonw.exe & pythonw.pdb to folder: C:\ProgramData\Anaconda3\lib\venv\scripts\nt\
That's because, in the python version you are trying create virtual environment venv [ in other cases -> vitualenv] has not been installed.
environment building process fails after python global version hand over to the specific version.
you can get idea how to install vitualenv on a specific version from the link below.
Dealing with multiple python versions and pip

Can't install apex on Windows

I want to install apex on my computer with Windows 10 and cuda 9.0. I know apex is not recommended to be installed on Windows, but I still very much want to try it. I used These two commands provided on apex official website:
pip install -v --no-cache-dir --global-option="--cpp_ext" --global-option="--cuda_ext"
and
pip install -v --no-cache-dir
but under both conditions got the error:
ERROR: You must give at least one requirement to install (see "pip help install")
The whole message is:
>pip install -v --no-cache-dir --global-option="--cpp_ext" --global-option="--cuda_ext"
C:\Users\Huiqi Xue\AppData\Local\conda\conda\envs\deeplearning\lib\site-packages\pip\_internal\commands\install.py:211: UserWarning: Disabling all use of wheels due to the use of --build-options / --global-options / --install-options.
cmdoptions.check_install_build_global(options)
Config variable 'Py_DEBUG' is unset, Python ABI tag may be incorrect
Config variable 'WITH_PYMALLOC' is unset, Python ABI tag may be incorrect
Created temporary directory: C:\Users\HUIQIX~1\AppData\Local\Temp\pip-ephem-wheel-cache-9dmaw_wt
Created temporary directory: C:\Users\HUIQIX~1\AppData\Local\Temp\pip-req-tracker-rf4_u0bh
Created requirements tracker 'C:\\Users\\HUIQIX~1\\AppData\\Local\\Temp\\pip-req-tracker-rf4_u0bh'
Created temporary directory: C:\Users\HUIQIX~1\AppData\Local\Temp\pip-install-bflvtp4e
Cleaning up...
Removed build tracker 'C:\\Users\\HUIQIX~1\\AppData\\Local\\Temp\\pip-req-tracker-rf4_u0bh'
ERROR: You must give at least one requirement to install (see "pip help install")
Exception information:
Traceback (most recent call last):
File "C:\Users\Huiqi Xue\AppData\Local\conda\conda\envs\deeplearning\lib\site-packages\pip\_internal\cli\base_command.py", line 143, in main
status = self.run(options, args)
File "C:\Users\Huiqi Xue\AppData\Local\conda\conda\envs\deeplearning\lib\site-packages\pip\_internal\commands\install.py", line 293, in run
self.name, wheel_cache
File "C:\Users\Huiqi Xue\AppData\Local\conda\conda\envs\deeplearning\lib\site-packages\pip\_internal\cli\base_command.py", line 252, in populate_requirement_set
'(see "pip help %(name)s")' % opts)
pip._internal.exceptions.CommandError: You must give at least one requirement to install (see "pip help install")
Config variable 'Py_DEBUG' is unset, Python ABI tag may be incorrect
Config variable 'WITH_PYMALLOC' is unset, Python ABI tag may be incorrect
1 location(s) to search for versions of pip:
You are probably getting the error because you missed the dot at the end of the command:
pip install -v --no-cache-dir --global-option="--cpp_ext" --global-option="--cuda_ext" .

Issue with dependencies running python file on another PC

I have a python file running perfectly in the IDE.
I want to run it on a different PC without any IDE.
I run the program from the command line: python program.py
Error message: File "program.py", line 8, in
from mpl_finance import candlestick_ohlc
ModuleNotFoundError: No module named 'mpl_finance'
When trying: pip install mpl_finance (or pip install mpl_toolkits)
I get the message: No matching distribution found for mpl_finance (or mpl_toolkits)
There also seems to be a problem with matplotlib backend.
Looking for a solution please.
After many failed paths, here's what worked:
matplotlib.finance is deprecated and it is now mpl_finance.
Create 2 files named mpl_finance.py and setup.py and get their contents from here.
Then from the command-line: python setup.py install
Fixing the backend (this can save you a few days):
If the backend of matplotlib was set in a file original PC (and not in the code). Then you need to do the same on the second PC.
Windows Path: C:\Program Files\Python36\Lib\site-packages\matplotlib\mpl-data\matplotlibrc
Change (probably line 38) to this: backend : Qt5Agg