简体   繁体   English

vagrantbox 中的“mkvirtualenv 命令未找到”

[英]“mkvirtualenv command not found” within vagrantbox

I am trying to set up a django project using vagrant, but I am getting this error:我正在尝试使用 vagrant 设置一个 django 项目,但出现此错误:

 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.如果重要的话,我已经安装了 python 3.6、3.5 和 anaconda。 Thank you for the help谢谢你的帮助

First of all destroy the vagrant box by running following command:首先,通过运行以下命令来销毁 vagrant box:

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.现在用vagrant init命令初始化你的 vagrant box,然后运行vagrant up命令。

Try this code in terminal when you entered into vagrant当您进入 vagrant 时,请在终端中尝试此代码

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

you have to change the path of file你必须改变文件的路径

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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