bash: mkvirtualenv: command not found

后端 未结 11 1429
天命终不由人
天命终不由人 2020-12-02 06:15

After following the instructions on Doug Hellman\'s virtualenvwrapper post, I still could not fire up a test environment.

[mpenning@tsunami ~]$ mkvirtualenv          


        
相关标签:
11条回答
  • 2020-12-02 06:57

    In order to successfully install the virtualenvwrapper on Ubuntu 18.04.3 you need to do the following:

    1. Install virtualenv

      sudo apt install virtualenv
      
    2. Install virtualenvwrapper

      sudo pip install virtualenv
      sudo pip install virtualenvwrapper
      
    3. Add the following to the end of the .bashrc file

      export WORKON_HOME=~/virtualenvs
      export VIRTUALENVWRAPPER_PYTHON=/usr/bin/python
      source ~/.local/bin/virtualenvwrapper.sh
      
    4. Execute the .bashrc file

      source ~/.bashrc
      
    5. Create your virtualenv

      mkvirtualenv your_virtualenv
      
    0 讨论(0)
  • 2020-12-02 06:58

    On Windows 7 and Git Bash this helps me:

    1. Create a ~/.bashrc file (under your user home folder)
    2. Add line export WORKON_HOME=$HOME/.virtualenvs (you must create this folder if it doesn't exist)
    3. Add line source "C:\Program Files (x86)\Python36-32\Scripts\virtualenvwrapper.sh" (change path for your virtualenvwrapper.sh)

    Restart your git bash and mkvirtualenv command now will work nicely.

    0 讨论(0)
  • 2020-12-02 06:59

    I had the same issue on OS X 10.9.1 with python 2.7.5. No issues with WORKON_HOME for me, but I did have to manually add source "/usr/local/bin/virtualenvwrapper.sh" to ~/.bash_profile (or ~/.bashrc in unix) after I ran pip install virtualenvwrapper

    0 讨论(0)
  • 2020-12-02 07:02

    Since I just went though a drag, I'll try to write the answer I'd have wished for two hours ago. This is for people who don't just want the copy&paste solution

    First: Do you wonder why copying and pasting paths works for some people while it doesn't work for others?** The main reason, solutions differ are different python versions, 2.x or 3.x. There are actually distinct versions of virtualenv and virtualenvwrapper that work with either python 2 or 3. If you are on python 2 install like so:

    sudo pip install virutalenv
    sudo pip install virtualenvwrapper
    

    If you are planning to use python 3 install the related python 3 versions

    sudo pip3 install virtualenv
    sudo pip3 install virtualenvwrapper
    

    You've successfully installed the packages for your python version and are all set, right? Well, try it. Type workon into your terminal. Your terminal will not be able to find the command (workon is a command of virtualenvwrapper). Of course it won't. Workon is an executable that will only be available to you once you load/source the file virtualenvwrapper.sh. But the official installation guide has you covered on this one, right?. Just open your .bash_profile and insert the following, it says in the documentation:

    export WORKON_HOME=$HOME/.virtualenvs
    export PROJECT_HOME=$HOME/Devel
    source /usr/local/bin/virtualenvwrapper.sh
    

    Especially the command source /usr/local/bin/virtualenvwrapper.sh seems helpful since the command seems to load/source the desired file virtualenvwrapper.sh that contains all the commands you want to work with like workon and mkvirtualenv. But yeah, no. When following the official installation guide, you are very likely to receive the error from the initial post: mkvirtualenv: command not found. Still no command is being found and you are still frustrated. So whats the problem here? The problem is that virtualenvwrapper.sh is not were you are looking for it right now. Short reminder ... you are looking here:

    source /usr/local/bin/virtualenvwrapper.sh
    

    But there is a pretty straight forward way to finding the desired file. Just type

    which virtualenvwrapper
    

    to your terminal. This will search your PATH for the file, since it is very likely to be in some folder that is included in the PATH of your system.

    If your system is very exotic, the desired file will hide outside of a PATH folder. In that case you can find the path to virtalenvwrapper.sh with the shell command find / -name virtualenvwrapper.sh

    Your result may look something like this: /Library/Frameworks/Python.framework/Versions/3.7/bin/virtualenvwrapper.sh Congratulations. You have found your missing file!. Now all you have to do is changing one command in your .bash_profile. Just change:

    source "/usr/local/bin/virtualenvwrapper.sh"
    

    to:

    "/Library/Frameworks/Python.framework/Versions/3.7/bin/virtualenvwrapper.sh"
    

    Congratulations. Virtualenvwrapper does now work on your system. But you can do one more thing to enhance your solution. If you've found the file virtualenvwrapper.sh with the command which virtualenvwrapper.sh you know that it is inside of a folder of the PATH. So if you just write the filename, your file system will assume the file is inside of a PATH folder. So you you don't have to write out the full path. Just type:

    source "virtualenvwrapper.sh"
    

    Thats it. You are no longer frustrated. You have solved your problem. Hopefully.

    0 讨论(0)
  • 2020-12-02 07:03

    Solved my issue in Ubuntu 14.04 OS with python 2.7.6, by adding below two lines into ~/.bash_profile (or ~/.bashrc in unix) files.

    source "/usr/local/bin/virtualenvwrapper.sh"

    export WORKON_HOME="/opt/virtual_env/"

    And then executing both these lines onto the terminal.

    0 讨论(0)
提交回复
热议问题