python环境搭建:
- 安装pyenv
git clone https://github.com/pyenv/pyenv.git ~/.pyenv
echo 'export PYENV_ROOT="$HOME/.pyenv"' >> ~/.bash_profile
echo 'export PATH="$PYENV_ROOT/bin:$PATH"' >> ~/.bash_profile
echo -e 'if command -v pyenv 1>/dev/null 2>&1; then\n eval "$(pyenv init -)"\nfi' >> ~/.bash_profile
-
安装python
建议先下载 Python-3.6.5.tar.xz
地址: https://www.python.org/ftp/python/3.6.5/Python-3.6.5.tar.xz
创建目录 .pyenv/cache
mv Python-3.6.5.tar.xz .pyenv/cache
安装命令:
pyenv install -v 3.6.5 -
centos部分库安装建议:
yum install readline readline-devel readline-static -y
yum install openssl openssl-devel openssl-static -y
yum install sqlite-devel -y
yum install bzip2-devel bzip2-libs -y
yum install libffi-devel -y
- debian系统
apt-get install build-essential -y
apt-get install libncurses5-dev libncursesw5-dev libreadline6-dev -y
apt-get install libdb5.3-dev libgdbm-dev libsqlite3-dev libssl-dev -y
apt-get install libbz2-dev libexpat1-dev liblzma-dev zlib1g-dev -y
apt-get install ca-certificates -y
apt-get install python-dev python-setuptools python-pip python-smbus
apt-get install libc6-dev tk-dev
apt-get install libffi-dev
ln /usr/lib/x86_64-linux-gnu/libssl.so.1.0.2 /usr/local/libssl.so
ln /usr/lib/x86_64-linux-gnu/libcrypto.so.1.0.2 /usr/local/libcrypto.so
-
产看所有版本:
pyenv versions
查看当前版本:
pyenv version
切换版本:
pyenv global 3.6.5 (建议python3.7 以上版本 用centos 7 以上系统) -
配置豆瓣源
HOME用户目录下
mkdir .pip
touch pip.conf -
编辑pip.conf:
[global]
timeout = 60
index-url = https://pypi.doubanio.com/simple
-
创建虚拟环境
python3 -m venv venv3.6 -
激活虚拟环境
source venv3.6/bin/activate -
安装依赖包
pip3 freeze > requirements.txt 生成依赖包
pip3 install -r requirements.txt
网友评论