python 虛擬環(huán)境

傳統(tǒng) virtualenvwrapper

sudo apt install virtualenv
sudo apt install virtualenvwrapper
sudo find / -name 'virtualenvwrapper.sh'
mkdir ~/.virtualenvs  or mkdir ~/envs
export WROKON_HOME=~/.virtualenvs       or  envs

###iwnodws 設(shè)置的時候 要小寫  workon_home 
source /usr/local/bin/virtualenvwrapper.sh  or  使用上馬find找到的 virtualenvwrapper.sh
#### 可以在root 下 .bashrc 最后添加一句export WROKON_HOME=/home/dfk/.virtualenvs 把目錄移到外面 方便pycharm導(dǎo)入
source ~/.bashrc

mkvirtualenv -p /usr/bin/python3 djangopy3

workon 

deactivate

pip freeze > rexx.txt 打印出所有包
pip install -i https://pypi.douban.com/simple -r rexx.txt 安裝所有包

新奇 pipenv

新建一個準(zhǔn)備當(dāng)環(huán)境的文件夾pipenvtest,并cd進(jìn)入該文件夾:
pipenv --three 會使用當(dāng)前系統(tǒng)的Python3創(chuàng)建環(huán)境

pipenv --python 3.6 指定某一Python版本創(chuàng)建環(huán)境

pipenv shell 激活虛擬環(huán)境

pipenv --where 顯示目錄信息
/home/jiahuan/pipenvtest

pipenv --venv 顯示虛擬環(huán)境信息
/home/jiahuan/.local/share/virtualenvs/pipenvtest-9KKRH3OW

pipenv --py 顯示Python解釋器信息
/home/jiahuan/.local/share/virtualenvs/pipenvtest-9KKRH3OW/bin/python

pipenv install requests 安裝相關(guān)模塊并加入到Pipfile

pipenv install django==1.11 安裝固定版本模塊并加入到Pipfile

pipenv graph 查看目前安裝的庫及其依賴

pipenv install 安裝模塊時有時候會很慢
可以設(shè)置國內(nèi)源:Pipfile文件中[source]下面url屬性,比如修改成:url = "https://pypi.tuna.tsinghua.edu.cn/simple"

ubuntu
升級python3.6
安裝:

1、add-apt-repository ppa:jonathonf/python-3.6

2、apt-get update

3、apt-get install python3.6

配置只輸入python3時就默認(rèn)使用3.6版本:

1、update-alternatives --install /usr/bin/python3 python3 /usr/bin/python3.5 1

2、update-alternatives --install /usr/bin/python3 python3 /usr/bin/python3.6 2

3、update-alternatives --config python3

4、python3 -V

設(shè)置pip:

1、apt-get install python3-pip    # Python3

2、apt-get install python-pip     # Python2

?著作權(quán)歸作者所有,轉(zhuǎn)載或內(nèi)容合作請聯(lián)系作者
平臺聲明:文章內(nèi)容(如有圖片或視頻亦包括在內(nèi))由作者上傳并發(fā)布,文章內(nèi)容僅代表作者本人觀點(diǎn),簡書系信息發(fā)布平臺,僅提供信息存儲服務(wù)。

推薦閱讀更多精彩內(nèi)容