17

I am trying to install Virtualenv wrapper on Ubuntu 14.04. But whenever I start a terminal, I get the error saying bash:

/usr/share/virtualenvwrapper/virtualenvwrapper_lazy.sh: No such file or directory.

I also checked the bashrc script by using gedit ~/.bashrc, but there is no such line like that. Does anyone know where I am wrong?

8
  • Have you checked other configuration files such as .bash_profile, and system-wide versions in /etc/?
    – user373230
    Mar 24, 2015 at 16:34
  • Yes I already checked .bash_profile, but it is empty and I dont know how to check /etc/. Mar 24, 2015 at 16:40
  • There should be un-hidden global files as /etc/bash.bashrc.
    – user373230
    Mar 24, 2015 at 16:42
  • Have a look at this source chrisstrelioff.ws/sandbox/2014/09/04/… which may assist you with some idea.
    – BDRSuite
    Mar 24, 2015 at 16:43
  • @vembutech I checked the above link, but it did not help.I already add path of my virtualenvwrapper.sh in my bashrc. But I didn't found any path like I described above in my question. Whenever I tried source ~/.bashrc, it gives the above error Mar 24, 2015 at 17:01

6 Answers 6

24

In my case, I had previously installed virtualenvwrapper using apt-get install virtualenvwrapper and later uninstalled it using apt-get remove virtualenvwrapper, which left the 'configuration' file /etc/bash_completion.d/virtualenvwrapper behind. This bash completion definition was sourced by bash (it had nothing to do with my .bashrc) and caused the error message.

The solution was to run:

sudo apt-get purge virtualenvwrapper

Which purged all files related to virtualenvwrapper. The reason I uninstalled it was to use pip's version instead (more up-to-date), which can be installed globally using:

sudo pip install virtualenvwrapper
3
  • I had this issue in sublime text 3 on OSX when building a script and to solve I just installed it via pip as your command states above. Thanks
    – james-see
    Feb 16, 2017 at 15:25
  • Worked for me on Ubuntu 16.04 Jul 16, 2018 at 8:22
  • Worked on Kubuntu 18.04 May 22, 2022 at 5:24
23

I just had the same problem on Linux Mint.

The following file was causing the issue: /etc/bash_completion.d/virtualenvwrapper

I made a backup (just in case) and deleted it, and everything seems to be working fine now.

3
  • 1
    Worked for me (+1). Dec 11, 2015 at 16:57
  • Worked for me on Ubuntu (+1)
    – lightsong
    Nov 28, 2019 at 9:17
  • Great tip, thanks. Don't leave the backup of this file in the bash_completion.d folder or it will not work as expected. Feb 11, 2022 at 22:04
5

Following these instructions, I found that the error occurred when sourcing the virtualenvwrapper bash script, i.e.:

source /usr/local/bin/virtualenvwrapper.sh

The script references the file /etc/bash_completion.d/virtualenvwrapper as pointed out by arcticfeather.

Open up the script using the following command:

sudo nano /etc/bash_completion.d/virtualenvwrapper

This is where the non-existent file is being referenced. Simply replace /usr/share/virtualenvwrapper/virtualenvwrapper_lazy.sh with /usr/local/bin/virtualenvwrapper_lazy.sh and you should be good to go!

1
  • 1
    Didn't work for me. Dec 11, 2015 at 16:57
1

If none of the answers work like for myself, just create an empty file at the location giving out an error and shebang to it.

In the case of OP:

sudo nano /usr/share/virtualenvwrapper/virtualenvwrapper_lazy.sh

and write:

#!/bin/bash

Save it and try to open terminal again, did the trick for me

1

You can install Extension to virtualenv for managing multiple virtual Python environments (virtualenvwrapper) in Ubuntu 14.04 from the Ubuntu Software Center or from the terminal using the following command:

sudo apt install virtualenvwrapper
gedit .bashrc

Add the following line to the end of .bashrc.

source /usr/share/virtualenvwrapper/virtualenvwrapper.sh

Save the changes to .bashrc and close gedit. Source your .bashrc for the changes to take effect.

cd 
source .bashrc
1
  • Didn't work for me. Dec 11, 2015 at 16:57
0

I hope it help someone, in my case i was trying to create the virtualenv being inside a screen (screen -S whatever), the solution was closing the screen and executing the virtualenv command again being outside.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .