pyenv環境部署
pyenv安裝使用git
[root@kang ~]# yum install git -ypython
python安裝依賴
yum -y install gcc make patch gdbm-devel openssl-devel sqlite-devel readline-devel zlib-devel bzip2-develgit
建立用戶python
useradd pythongithub
使用python用戶登陸
curl -L https://raw.githubusercontent.com/pyenv/pyenv-installer/master/bin/pyenv-installer | bashsql
在pythonet用戶的.~/.bashrc中追加:
export PATH="/home/python/.pyenv/bin:$PATH"
eval "$(pyenv init -)"
eval "$(pyenv virtualenv-init -)"vim
[python@kang ~]$ source .bashrccentos
pyenv -v install 3.5.3 #按裝指定版本bash
pip通用配置:
mkdir ~/.pip
vim ~/.pip/pip.conf
[global]
index-url=https://mirrors.aliyun.com/pypi/simple/trusted-host=mirrors.aliyun.comcurl
使用虛擬環境插件Virtualenv
pyenv virtualenv 3.5.3(版本) LHtest(別名)ide
[python@kang lhpython3]$ pyenv virtualenv 3.5.3 lhtest353
[python@kang lhpython3]$ pyenv local lhtest353fetch
升級pip遇到的坑
(lhtest353) [python@kang lhpython3]$ pip install --upgrade pip
Requirement already up-to-date: pip in /home/python/.pyenv/versions/3.5.3/envs/lhtest353/lib/python3.5/site-packages
You are using pip version 9.0.1, however version 19.2.3 is available.
You should consider upgrading via the 'pip install --upgrade pip' command.
能夠查看詳細報錯
(lhtest353) [python@kang lhpython3]$ pip install --upgrade pip -vvv
1 location(s) to search for versions of pip:
* https://mirrors.aliyun.com/pypi/simple/trusted-host=mirrors.aliyun.com/pip/
Getting page https://mirrors.aliyun.com/pypi/simple/trusted-host=mirrors.aliyun.com/pip/
Looking up "https://mirrors.aliyun.com/pypi/simple/trusted-host=mirrors.aliyun.com/pip/" in the cache
No cache entry available
Starting new HTTPS connection (1): mirrors.aliyun.com
"GET /pypi/simple/trusted-host=mirrors.aliyun.com/pip/ HTTP/1.1" 404 2517
Status code 404 not in [200, 203, 300, 301]
Could not fetch URL https://mirrors.aliyun.com/pypi/simple/trusted-host=mirrors.aliyun.com/pip/: 404 Client Error: Not Found for url: https://mirrors.aliyun.com/pypi/simple/trusted-host=mirrors.aliyun.com/pip/ - skipping
Installed version (9.0.1) is most up-to-date (past versions: none)
Requirement already up-to-date: pip in /home/python/.pyenv/versions/3.5.3/envs/lhtest353/lib/python3.5/site-packages
Cleaning up...
You are using pip version 9.0.1, however version 19.2.3 is available.
You should consider upgrading via the 'pip install --upgrade pip' command.
--------------
刪除先前配置的加速站點:
pip通用配置:
mkdir ~/.pip
vim ~/.pip/pip.conf
[global]
index-url=https://mirrors.aliyun.com/pypi/simple/trusted-host=mirrors.aliyun.com
---------------------
(lhtest353) [python@kang lhpython3]$ pip install Django==1.11.18
pycharm 配置遠程主機信息(centos)
~/home/.pyenv/versions/3.5.2/bin/python3.5