Python3安装与配置venv虚拟环境

2023-01-31 02:01:25 配置 安装 虚拟

python3安装与配置venv虚拟环境

  • 创建安装目录
  • 下载适宜的版本([传送门](https://www.python.org/ftp/Python/))
  • 解压
  • config
  • 安装
  • 配置Python3软连接
  • 验证python3环境
  • 升级 pip
  • 安装venv
  • 创建代码目录
  • 创建venv虚拟工作环境
  • 查看 venv虚拟环境
  • 拉代码
  • 升级venv pip3
  • 安装环境依赖
  • 运行

mkdir -p /usr/local/python3  && cd /usr/local/python3/
wget Https://www.python.org/ftp/python/3.6.6/Python-3.6.6.tgz
tar -vzxf Python-3.6.6.tgz && cd Python-3.6.6
./configure --prefix=/usr/local/python3/Python-3.6.6
make  &&  make install
ln -s /usr/local/python3/Python-3.6.6/bin/python3.6 /usr/bin/python3
ln -s /usr/local/python3/Python-3.6.6/bin/pip3 /usr/bin/pip3
[root@localhost bin]# python3
Python 3.6.6 (default, Nov 14 2018, 18:41:59) 
[GCC 4.4.7 20120313 (Red Hat 4.4.7-23)] on linux
Type "help", "copyright", "credits" or "license" for more infORMation.
>>> exit()
#-i http://mirrors.aliyun.com/pypi/simple/ --trusted-host mirrors.aliyun.com 指定使用阿里云的源,可以不加
pip3 install --upgrade pip -i http://mirrors.aliyun.com/pypi/simple/ --trusted-host mirrors.aliyun.com
pip3 install virtualenv -i http://mirrors.aliyun.com/pypi/simple/ --trusted-host mirrors.aliyun.com
mkdir -p /data/code/python && cd  /data/code/python
python3 -m venv /data/code/python/venv_proxy_pool
[root@oracledb venv_proxy_pool]# ls -l
总用量 16
drwxr-xr-x 2 root root 4096 11月 14 19:08 bin
drwxr-xr-x 2 root root 4096 11月 14 19:08 include
drwxr-xr-x 3 root root 4096 11月 14 19:08 lib
lrwxrwxrwx 1 root root    3 11月 14 19:08 lib64 -> lib
-rw-r--r-- 1 root root   69 11月 14 19:08 pyvenv.cfg
cd /data/code/python/venv_proxy_pool/
git clone  https://GitHub.com/jhao104/proxy_pool.git
/data/code/python/venv_proxy_pool/bin/pip3 install --upgrade pip -i http://mirrors.aliyun.com/pypi/simple/ --trusted-host mirrors.aliyun.com
/data/code/python/venv_proxy_pool/bin/pip3 install -r /data/code/python/venv_proxy_pool/proxy_pool/requirements.txt -i http://mirrors.aliyun.com/pypi/simple/ --trusted-host mirrors.aliyun.com
cd /data/code/python/venv_proxy_pool/proxy_pool/Run/
/data/code/python/venv_proxy_pool/bin/python3 main.py 

相关文章