bash: mkvirtualenv: command not found

后端 未结 11 1496
天命终不由人
天命终不由人 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:50

    Use this procedure to create virtual env in ubuntu

    step 1

    Install pip

       sudo apt-get install python-pip
    

    step 2

    Install virtualenv

       sudo pip install virtualenv
    

    step 3

    Create a dir to store your virtualenvs (I use ~/.virtualenvs)

       mkdir ~/.virtualenvs
    

    or use this command to install specific version of python in env

    virtualenv -p /usr/bin/python3.6 venv
    

    step 4

       sudo pip install virtualenvwrapper
    

    step 5

       sudo nano ~/.bashrc
    

    step 6

    Add this two line code at the end of the bashrc file

      export WORKON_HOME=~/.virtualenvs
      source /usr/local/bin/virtualenvwrapper.sh
    

    step 7

    Open new terminal (recommended)

    step 8

    Create a new virtualenv

      mkvirtualenv myawesomeproject
    

    step 9

    To load or switch between virtualenvs, use the workon command:

      workon myawesomeproject
    

    step 10

    To exit your new virtualenv, use

     deactivate
    

    and make sure using pip vs pip3

    OR follow the steps below to install virtual environment using python3

    Install env

    python3 -m venv my-project-env
    

    and activate your virtual environment using the following command:

    source my-project-env/bin/activate
    

提交回复
热议问题