Home > Software engineering >  FileExistsError: [Errno 17] File exists: '/usr/bin/python' -> '/home/had2000/.virt
FileExistsError: [Errno 17] File exists: '/usr/bin/python' -> '/home/had2000/.virt

Time:12-17

When i have python 3.5 and python 3.6 on ubuntu .I entered some alternate commands to use python 3.5 only (when I type python -V and python3 -V the same output is 3.5.2)

And then i install virtualenv and virtualenvwrapper — these packages allow me to create and manage Python virtual environments:
$ sudo pip install virtualenv virtualenvwrapper
$ sudo rm -rf ~/get-pip.py ~/.cache/pip

To finish the install of these tools, I updated our ~/.bashrc file.I added the following lines to your ~/.bashrc :
export WORKON_HOME=$HOME/.virtualenvs
export VIRTUALENVWRAPPER_PYTHON=/usr/bin/python3
source /usr/local/bin/virtualenvwrapper.sh
Next, source the ~/.bashrc file:
$ source ~/.bashrc

And final I created your OpenCV 4 Python 3 virtual environment:
$ mkvirtualenv cv -p python3

i have created the virtual environment but had some problems in the back end and i guess it was due to the presence of python3.6. In the end i decided to uninstall python 3.6 and rerun the steps above from scratch and had a problem at the last step that I mentioned above.When i enter command "mkvirtualenv cv -p python3" i get an ERROR:
FileExistsError: [Errno 17] File exists: '/usr/bin/python' -> '/home/had2000/.virtualenvs/cv/bin/python'

At the same time when i enter the command "update-alternatives --config python" python3.6 is no longer there,but i get a warning:
update-alternatives: warning: alternative /usr/bin/python3.6 (part of link group python) doesn't exist; removing from list of alternatives
There is 1 choice for the alternative python (providing /usr/bin/python).

Looking forward to your help, thank you

CodePudding user response:

From the commands you've shared, the error arises from the mkvirtualenv cv being run twice - i.e. the environment already exists. To remove the environment you created, do: rmvirtualenv env-name-here which in this case will become rmvirtualenv cv. This shouldn't be done with that environment active, BTW. An alternate route is to delete $WORKON_HOME/env-name-here. By default, $WORKON_HOME is usually .virtualenvs.

  • Related