-bash: /usr/bin/virtualenvwrapper.sh: No such file or directory
Asked Answered
R

9

23

I can't figure out where the shell is trying to run /usr/bin/virtualenvwrapper.sh upon server login. I want virtualenvwrapper permanently uninstalled, not just removed from the shell instance. I thought I uninstalled it with pip uninstall virtualenvwrapper, but every time I log into the server I get the error -bash: /usr/bin/virtualenvwrapper.sh: No such file or directory, as if there is some sort of leftover artifact. Yesterday I did a lot of tinkering and I can't remember all the changes I made or how I made this happen. Where is it executing the search for virtualenvwrapper.sh?

SUPPLEMENTARY INFO

$ echo $PATH
/usr/lib64/qt-3.3/bin
/usr/local/bin/ibm/lsf/9.1/linux2.6-glibc2.3-x86_64/etc
/usr/local/bin/ibm/lsf/9.1/linux2.6-glibc2.3-x86_64/bin
/usr/local/bin
/bin
/usr/bin
/usr/local/sbin
/usr/sbin
/sbin/usr/local/bin/CASAVA-1.8.2/bin
/usr/local/bin/blast
/usr/local/bin/mirdeep2
/usr/local/bin/velvet

$ sudo vim ~/.bashrc
1 # .bashrc
2
3 # Source global definitions
4 if [ -f /etc/bashrc ]; then
5         . /etc/bashrc
6 fi
7
8 # User specific aliases and functions
Repartee answered 13/1, 2016 at 17:14 Comment(5)
Also check /etc/bash.bashrc for any use of that file.Invasion
I don't have /etc/bash.bashrc. Tis empty.Repartee
Have you checked your ~/.bashrc, ~/.bash_profile, ~/.bash_login and ~/.profile for "/usr/bin/virtualenvwrapper.sh"?Paulettepauley
found it! It's in the ~/.bash_profile. Thank you. Can you answer it so I can mark it correct?Repartee
done! thanks @ReparteePaulettepauley
P
9

There are a number of files that might be run when you login to your terminal if you are using the bash shell.

You should check ~/.bashrc, ~/.bash_profile, ~/.bash_login and ~/.profile for "/usr/bin/virtualenvwrapper.sh".

Likely one of those files is being run on login and contains the missing script which you uninstalled.

Paulettepauley answered 13/1, 2016 at 17:24 Comment(1)
Yep. I had a line in my .bash_profile related to an old project that was using local env. Comment out/delete the line and you are good to go. ThanksMoldy
P
53

on ubuntu 12.04 LTS, installing through pip, it is installed to

/usr/local/bin/virtualenvwrapper.sh

And if you are using Ubuntu 16.04 or later, it is installed to

~/.local/bin/virtualenvwrapper.sh
Peerless answered 16/4, 2018 at 13:21 Comment(1)
I also needed export VIRTUALENVWRAPPER_ENV_BIN_DIR=bin working on Raspberry Pi3 and Pi4. Not sure why or whether this is specific, because I just 'wanted it to work'.Inoperative
Q
12

Setting up a Virtual Environment Now open your terminal in the home directory by right clicking and choosing the option “Open in Terminal”. You can also press the CTRL, ALT, and T keys on your keyboard at the same time to open the Terminal application automatically.

You first need to create a special directory that will hold all of your virtual environments. So proceed with creating a new hidden directory called virtualenv.

$ mkdir .virtualenv

Now you should install pip for Python3.

$ sudo apt install python3-pip

Confirm the pip3 installation.

$ pip3 --version

Now install virtualenv via pip3.

$ pip3 install virtualenv

To find where your virtualenv was installed, type:

$ which virtualenv

Install virtualenvwrapper via pip3:

$ pip3 install virtualenvwrapper

We are going to modify your .bashrc file by adding a row that will adjust every new virtual environment to use Python 3. We will point virtual environments to the directory we created above (.virtualenv) and we will also point to the locations of the virtualenv and virtualenvwrapper.

Now open the .bashrc file using Vim editor.

$ vim .bashrc

If you still haven’t used the Vim editor or you don’t have it installed on your computer you should install it now. It is a widely used Linux editor, and for good reason.

$ sudo apt install vim

After you've installed Vim open the file .bashrc file by typing the vim .bashrc command in your terminal. Navigate to the bottom of the .bashrc file, press the letter i to enter the insert mode of Vim, and add these rows:

#Virtualenvwrapper settings:
export VIRTUALENVWRAPPER_PYTHON=/usr/bin/python3
export WORKON_HOME=$HOME/.virtualenvs
export VIRTUALENVWRAPPER_VIRTUALENV=/home/your_username/.local/bin/virtualenv
source ~/.local/bin/virtualenvwrapper.sh

After you are done, press the esc key. Then type :wq and press enter. This command will save and exit the Vim editor. Close and reopen your terminal when you’re done.

To create a virtual environment in Python3 and activate it immediately, use this command in your terminal:

$ mkvirtualenv name_of_your_env

You should confirm that this environment is set up for Python3:

$ Python -V

To deactivate the environment use the deactivate command.

$ deactivate

To list all available virtual environments use the command workon or lsvirtualenv (same result as workon but shown in a fancy way) in your terminal:

$ workon

$ lsvirtualenv

To activate one specific environment use workon + name of your environment:

$ workon name_of_your_env

There are several useful command you might need to use someday:

Rmvirtualenv will remove a specific virtual environment located in your .virtualenv directory.

$ rmvirtualenv name_of_your_env

Cpvirtualenv will copy the existing virtual environment to a new virtual environment and activate it.

$ cpvirtualenv old_virtual_env new_virtual_env

Well done! You have now created your first isolated Python 3 environment.

Queer answered 12/1, 2021 at 15:59 Comment(2)
great answer, covers everything, next time also add the command 'source .bashrc' to reload the bash script as this helps people using remote instancesCrwth
The question asks how to remove this utility, not how to revive it.Unleavened
P
9

There are a number of files that might be run when you login to your terminal if you are using the bash shell.

You should check ~/.bashrc, ~/.bash_profile, ~/.bash_login and ~/.profile for "/usr/bin/virtualenvwrapper.sh".

Likely one of those files is being run on login and contains the missing script which you uninstalled.

Paulettepauley answered 13/1, 2016 at 17:24 Comment(1)
Yep. I had a line in my .bash_profile related to an old project that was using local env. Comment out/delete the line and you are good to go. ThanksMoldy
P
8

It can be that you python packages are installed somewhere else. So try:

$ which python
/home/tesla/miniconda3/bin/python

or

$ which virtualenvwrapper.sh
/home/tesla/miniconda3/bin/virtualenvwrapper.sh    

To check the location of python installation. In my case I was using miniconda, therefore system was not able to find the location mentioned in the documentation. If the above location is not /usr/local/bin/virtualenvwrapper.sh then now use :

source /home/tesla/miniconda3/bin/virtualenvwrapper.sh

Should work.

UPDATE Nov-2022:

I would recommend using pipenv (official docs) for creating and managing virtual environments.

Piccadilly answered 19/7, 2021 at 5:42 Comment(1)
My virtualenvwrapper.sh was located at "/Library/Frameworks/Python.framework/Versions/3.9/bin/virtualenvwrapper.sh" and not "/usr/local/bin". This worked for me.Mandate
P
5

For anyone finding this in the future. The virtualenvwrapper.sh script is/was now located at /usr/share/virtualenvwrapper/virtualenvwrapper.sh on Ubuntu 20.04.1 LTS (at least for me in my VM).

(Sadly i can't just comment on the above post mentioning the locations so it would all be together, because new user reputation)

Prestige answered 9/11, 2020 at 14:53 Comment(2)
Mine on Pop!_OS 21.04 is in the location indicated by Tarique's post. Ubuntu users should exercise caution. If a user using native Ubuntu 21.04 LTS could comment on where theirs is that'd be helpful to clarify what the status quo is for the current stable Ubuntu LTS.Herakleion
Thanks, this is also true on Debian 11 Bullseye. Why do they have to move these things and not tell anyone..Deferent
L
2

sudo -H pip3 install virtualenvwrapper

i ran into to similar problem where installation could not suceed because ~/.cache/pip and ~/.cache/pip/http is not owned by the current user. installing with -H or --set-home option solved my problem.

Libertinism answered 19/11, 2019 at 16:33 Comment(0)
A
2

Confirmed for Ubuntu 18 , as already answered by @Tarique . The shell script virtualenvwrapper.sh for the wrapper is within - ~/.local/bin/

(base) dhankar@dhankar-1:~/opencv_cuda$ cd ~/.local/bin/
(base) dhankar@dhankar-1:~/.local/bin$ ls -ltr
total 100
-rwxr-xr-x 1 dhankar dhankar 41703 Jul 23 20:56 virtualenvwrapper.sh
-rwxr-xr-x 1 dhankar dhankar  2210 Jul 23 20:56 virtualenvwrapper_lazy.sh
-rwxr-xr-x 1 dhankar dhankar   259 Jul 23 20:56 virtualenv
Amphibious answered 23/7, 2020 at 15:43 Comment(0)
D
1

I also confronted the same problem, but this worked for me: -

  1. Create a directory to hold the virtual environments.mkdir $HOME/.virtualenvs
  2. Add a line like export WORKON_HOME=$HOME/.virtualenvsto your .bashrc.
  3. Add a line like source /path/to/this/file/virtualenvwrapper.sh to your .bashrc.
  4. Run: source ~/.bashrc
  5. Run: mkvirtualenv temp
  6. This time, the "temp" environment is included.
  7. Run: workon temp
  8. The virtual environment is activated.

If you are on Ubuntu 20 then use the code given below in ~/.bashrc

export WORKON_HOME=~/.virtualenvs
export VIRTUALENVWRAPPER_PYTHON=/usr/bin/python3
export VIRTUALENVWRAPPER_VIRTUALENV=~/.local/bin/virtualenv
VIRTUALENVWRAPPER_PYTHON=/usr/bin/python3
source ~/.local/bin/virtualenvwrapper.sh
Damara answered 23/3, 2021 at 12:19 Comment(2)
The third line should be ~/.local/bin/virtualenv, where there is a space.Verlinevermeer
The question asks how to remove this utility, not how to revive it.Unleavened
T
1

In my case on Ubuntu 20, I found this script in:

/usr/share/virtualenvwrapper/
Thence answered 25/3, 2022 at 7:29 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.