简体   繁体   中英

Getting "`mkvirtualenv: command not found`" after installing virtualenvwrapper on Ubuntu 20.04

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?

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"'[^/]*$'

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM