如何正确的使用 virtualenvwrapper

in python •  6 years ago 

作为一名 Python 开发者。

不会用 **virtualenvwrapper** 我真的只能无语了。


* 安装并激活



```.shell

pip install virtualenvwrapper

source /usr/local/bin/virtualenvwrapper.sh

echo "source /usr/local/bin/virtualenvwrapper.sh" >> ~/.profile

```




* 接着,来创建一个 Django 的虚拟环境


```.bash

mkvirtualenv -p `which python3` -r /path/to/requirements.txt django


```




> 注:


    > -p 指定 python 的运行环境


    > -r 创建虚拟环境后安装相关的 python 包




* 最后, 我们就可以愉快的 workon 了


```.shell

workon django

```


* tips:



> 可以将 Django 的配置加入到  **$VIRTUAL_ENV/bin/postactivate**



```.shell

cat >> $VIRTUAL_ENV/bin/postactivate

export DJANGO_SETTINGS_MODULE=xxxxxx.settings.stage

```

Authors get paid when people like you upvote their post.
If you enjoyed what you read here, create your account today and start earning FREE STEEM!
Sort Order:  

Congratulations @jiaxin! You received a personal award!

Happy Birthday! - You are on the Steem blockchain for 1 year!

You can view your badges on your Steem Board and compare to others on the Steem Ranking

Vote for @Steemitboard as a witness to get one more award and increased upvotes!