-1

On Ubuntu v20.04, I have just installed virtualenv and virtualenvwrapper using apt with the commands:

sudo apt install virtualenv 
sudo apt install virtualenvwrapper

I did not get any errors or warnings.

When I try to run mkvirtualenv, which is claimed to be in virtualenvwrapper, I get:

mkvirtualenv: command not found

This question presents an old solution (from 8 years ago) consisting of locating the file virtualenvwrapper.sh and adding it to the source.

However, this doesn't work anymore. When I type source "/usr/bin/virtualenvwrapper.sh", I get

bash: /usr/bin/virtualenvwrapper.sh: No such file or directory

When I use locate or find to search for this file throughout the computer, I get no results. When I type which virtualenvwrapper I get no result.

Trying to re-install the module again, I get:

sudo apt install virtualenvwrapper
Reading package lists... Done
Building dependency tree       
Reading state information... Done
virtualenvwrapper is already the newest version (4.8.4-4).
0 to upgrade, 0 to newly install, 0 to remove and 18 not to upgrade.

What to do?

Gino Mempin
  • 25,369
  • 29
  • 96
  • 135
Luiz Ventura
  • 29
  • 1
  • 7
  • 2
    `dpkg-query -L` show that the package installs the file `/usr/share/virtualenvwrapper/virtualenvwrapper.sh`. Perhaps you should source that. – William Pursell Dec 26 '20 at 02:30
  • why do you install it with `atp` ? why not with `pip install virtualenv` ? – furas Dec 26 '20 at 02:34
  • I can't install with `pip` because I'm using Anaconda. Thanks for giving my question a downvote, really appreciate it. – Luiz Ventura Dec 26 '20 at 03:04
  • 1
    Please specify which version of which Linux distro the system in question is running. – agc Dec 26 '20 at 06:30
  • Solved it with `dpkg-query -L`, then I found the file `virtualenvwrapper.sh` and could use `source` on that. I didn't know about this very specific command `dpkg-query -L`. Why weren't `find` or `locate` able to locate the file? Perhaps those commands are broken? I'm using Ubuntu 20.04, sorry, I thought I had specified this. – Luiz Ventura Dec 26 '20 at 17:17

1 Answers1

-1

User phd comments that mkvirtualenv is not an executable, it's a shell function provided by virtualenvwrapper.sh. But if you don't know that to begin with, how would you find out? Some tips:

  1. Perhaps the executable name itself ("mkvirtualenv") is incorrect. On my system, where neither package, virtualenv or virtualenvwrapper, is installed, if the user attempts to run any program name that's not installed but could be installed, the command-not-found package will print an error message showing what package might need to be installed.

    It works even with similar sounding names -- so if we run a nonexistent command:

    bbash
    

    The output is:

    Command 'bbash' not found, did you mean:
    
      command 'bash' from deb bash (5.0-6ubuntu1.1)
      command 'rbash' from deb bash (5.0-6ubuntu1.1)
    
    Try: apt install <deb name>
    

    But if, on Linux Mint 20, I run the executable name given in the question:

    mkvirtualenv
    

    The output is:

    mkvirtualenv: command not found
    

    ...which implies such a command isn't even installable.

  2. To find out the actual names and paths of programs installed with a given package that's already been installed on your system, use dlocate -lsbin ..., like so:

    dlocate -lsbin virtualenv virtualenvwrapper
    
  3. To find the name of a not installed package containing a known file name, use apt-file:

    apt-file find virtualenv
    

    ...which finds the string "virtualenv" in the pathnames of all installable packages.

    To narrow the list to only file basenames that include the string "virtualenv", do:

    f=virtualenv
    apt-file find $f | grep '[^/]*'"$f"'[^/]*$'
    
agc
  • 7,973
  • 2
  • 29
  • 50
  • 1
    You don't need `dlocate`, you can simply run `dpkg -L` which is standard on every Debian-based system (or just inspect `/var/lib/dpkg/info/package.list` directly). – tripleee Dec 26 '20 at 07:05
  • 1
    The `command-not-found` handler is specific to Ubuntu. – tripleee Dec 26 '20 at 07:15
  • @tripleee, Not the same: `dpkg -L` lists *all* files in a package, but `dlocate -lsbin` lists only the executables. – agc Dec 26 '20 at 07:18
  • 1
    True, but it doesn't do anything very fancy; basically, `grep 'bin/'` – tripleee Dec 26 '20 at 08:33
  • 1
    `mkvirtualenv` is not an executable, it's a shell function provided by `virtualenvwrapper.sh`. – phd Dec 26 '20 at 10:12