赞
踩
yum install -y zlib-devel bzip2-devel libffi-devel openssl-devel ncurses-devel sqlite-devel readline-devel tk-devel gcc make
yum install libffi-devel -y
wget https://www.python.org/ftp/python/3.9.13/Python-3.9.13.tgz
tar -zxvf Python-3.9.13.tgz
cd Python-3.9.13
./configure --prefix=/usr/local/python39
make&&make install
建立命令软链接
先查看python2和python3安装在哪
which python
which python3
ln -s /usr/local/python39/bin/python3 /usr/bin/python3
ln -s /usr/local/python39/bin/pip3 /usr/bin/pip3
查看版本号
python3 -V
如果安装的python不带pip,可以通过以下命令安装
curl https://bootstrap.pypa.io/get-pip.py -o get-pip.py #下载安装脚本
python get-pip.py #运行安装脚本
python.exe -m pip install --upgrade pip
如果觉得国外源慢,可以使用以下国内源
#阿里云
https://mirrors.aliyun.com/pypi/simple/
#中国科技大学
https://pypi.mirrors.ustc.edu.cn/simple/
#豆瓣(douban)
https://pypi.douban.com/simple/
#清华大学
https://pypi.tuna.tsinghua.edu.cn/simple/
#中国科学技术大学
https://pypi.mirrors.ustc.edu.cn/simple/
pip -V
pip install package
# 指定版本和更新源安装
pip install -i https://mirrors.aliyun.com/pypi/simple/ numpy==1.23.2
pip list
pip uninstall package
pip show package
pip list --outdated
pip install --upgrade package
pip-review --local --interactive
通requirements.txt批量安装
为项目生成依赖包配置文件requirements.txt
pip freeze > requirements.txt
根据requirements.txt批量安装依赖包
pip install -r requirements.txt
官网下载:https://www.anaconda.com/download/
清华镜像:https://mirrors.tuna.tsinghua.edu.cn/anaconda/archive/
# 创建一个新的环境:
conda create -n python310 python=3.10
## 激活环境:
conda activate python310
# 退出环境:
conda deactivate
# 列出所有环境:
conda env list
# 删除环境:
conda env remove --name python310
# 安装包: conda install 包名 #安装特定版本的包: conda install 包名=版本号 #升级包: conda update 包名 #卸载包: conda remove 包名 #搜索包: conda search 包名 #搜索版本处于1.0.0及1.1之间的pandas conda search "pandas [version='>=1.0.0,<1.1']"
# 导出环境到文件:
conda env export > 环境文件.yml
# 从环境文件创建环境:
conda env create -f 环境文件.yml
#克隆环境:
conda create --clone 源环境名称 --name 新环境名称
#显示已安装的包列表:
conda list
# 显示包的详细信息:
conda info 包名
# 显示conda的版本信息:
conda --version
# 显示conda的帮助信息:
conda --help
# 1.配置清华镜像源 conda config --add channels https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/free/ conda config --add channels https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/main/ conda config --add channels https://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud/conda-forge/ #设置搜索时显示通道地址 conda config --set show_channel_urls yes # 2.配置中科大镜像源 conda config --add channels https://mirrors.ustc.edu.cn/anaconda/pkgs/main/ conda config --add channels https://mirrors.ustc.edu.cn/anaconda/pkgs/free/ conda config --add channels https://mirrors.ustc.edu.cn/anaconda/cloud/conda-forge/ conda config --add channels https://mirrors.ustc.edu.cn/anaconda/cloud/msys2/ conda config --add channels https://mirrors.ustc.edu.cn/anaconda/cloud/bioconda/ conda config --add channels https://mirrors.ustc.edu.cn/anaconda/cloud/menpo/ # 3、配置上海交通大学镜像源 conda config --add channels https://mirrors.sjtug.sjtu.edu.cn/anaconda/pkgs/main/ conda config --add channels https://mirrors.sjtug.sjtu.edu.cn/anaconda/pkgs/free/ conda config --add channels https://mirrors.sjtug.sjtu.edu.cn/anaconda/cloud/conda-forge/ # 显示添加的镜像源 conda config --show channels
Copyright © 2003-2013 www.wpsshop.cn 版权所有,并保留所有权利。