简体   繁体   中英

“mkvirtualenv command not found” within vagrantbox

I am trying to set up a django project using vagrant, but I am getting this error:

 Welcome to Ubuntu 16.04.3 LTS (GNU/Linux 4.4.0-112-generic x86_64)

 * Documentation:  https://help.ubuntu.com
 * Management:     https://landscape.canonical.com
 * Support:        https://ubuntu.com/advantage

  Get cloud support with Ubuntu Advantage Cloud Guest:
    http://www.ubuntu.com/business/services/cloud

0 packages can be updated.
0 updates are security updates.


Last login: Sun Jan 28 08:21:28 2018 from 10.0.2.2
vagrant@ubuntu-xenial:~$ mkvirtualenv profiles_api --python=python3
mkvirtualenv: command not found

In my vagrant file I have the following :

sudo pip install virtualenvwrapper
    if ! grep -q VIRTUALENV_ALREADY_ADDED /home/ubuntu/.bashrc; then
        echo "# VIRTUALENV_ALREADY_ADDED" >> /home/ubuntu/.bashrc
        echo "WORKON_HOME=~/.virtualenvs" >> /home/ubuntu/.bashrc
        echo "PROJECT_HOME=/vagrant" >> /home/ubuntu/.bashrc
        echo "source /usr/local/bin/virtualenvwrapper.sh" >> /home/ubuntu/.bashrc
    fi

I have python 3.6,3.5 and anaconda installed, if that matters. Thank you for the help

First of all destroy the vagrant box by running following command:

vagrant destroy

Change your vagrant file to this:

sudo pip install virtualenvwrapper

if ! grep -q VIRTUALENV_ALREADY_ADDED /home/vagrant/.bashrc; then
    echo "# VIRTUALENV_ALREADY_ADDED" >> /home/vagrant/.bashrc
    echo "WORKON_HOME=~/.virtualenvs" >> /home/vagrant/.bashrc
    echo "PROJECT_HOME=/vagrant" >> /home/vagrant/.bashrc
    echo "source /usr/local/bin/virtualenvwrapper.sh" >> /home/vagrant/.bashrc
fi

Now initialize your vagrant box with vagrant init command and then run vagrant up command.

Try this code in terminal when you entered into vagrant

export WORKON_HOME=~/Envs
mkdir -p $WORKON_HOME
source /usr/local/bin/virtualenvwrapper.sh

you have to change the path of file

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