标签:date native upd xen pip center etc apt ubuntu
sudo cp /etc/apt/sources.list /etc/apt/sources.list.bak
然后更改源文件为清华大学开源软件镜像站
sudo vim /etc/apt/sources.list
deb https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ xenial main restricted universe multiverse deb https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ xenial-updates main restricted universe multiverse deb https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ xenial-backports main restricted universe multiverse deb https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ xenial-security main restricted universe multiverse
添加python3.6的仓库
sudo add-apt-repository ppa:jonathonf/python-3.6
更新源
sudo apt-get update
更新安装源后,输入如下命令安装Python3.6:
sudo apt-get install python3.6
安装完成之后,设置Python3.6的优先级,输入如下命令:
sudo update-alternatives --install /usr/bin/python3 python3 /usr/bin/python3.5 1 sudo update-alternatives --install /usr/bin/python3 python3 /usr/bin/python3.6 2
下一步,我们来更新pip,输入如下代码:
sudo apt-get install python3-pip sudo pip3 install --upgrade pip
至此,python升级完成
输入pip -V
查看pip指向地址,是指向python3还是python2
[global] index-url = http://mirrors.aliyun.com/pypi/simple trusted-host = mirrors.aliyun.com
pip install virtualenv --user
pip install virtualenvwrapper --user
查看virtualenvwrapper.sh位置
which virtualenvwrapper.sh
编辑~/.bashrc文件
sudo vim ~/.bashrc
export WORKON_HOME=$HOME/.virtualenvs export PROJECT_HOME=$HOME/workspace source /usr/local/bin/virtualenvwrapper.sh(更换为上面查到的位置)
然后执行
source ~/.bashrc
到这里,虚拟环境也已经安装好了
mkvirtualenv django_test -p python3
rmvirtualenv django_test
workon django_test
如果创建虚拟环境的时候出现/usr/bin/python: No module named virtualenvwrapper
那么就编辑~/.bashrc文件
export WORKON_HOME=$HOME/.virtualenvs export VIRTUALENVWRAPPER_PYTHON=/usr/bin/python3 export VIRTUALENVWRAPPER_VIRTUALENV=/usr/local/bin/virtualenv export PROJECT_HOME=$HOME/workspace source /home/ubuntu/.local/bin/virtualenvwrapper.sh
标签:date native upd xen pip center etc apt ubuntu
原文地址:https://www.cnblogs.com/blog-rui/p/11169023.html