安装
http://www.python.org/download/
1 2 3 4 5 6 7
| #指定python的安装路径 ❯ ./configure --prefix=/home/cs/.local/py3.10 --enable-optimizations
❯ make -j8 ❯ make install
❯ /home/cs/.local/py3.10/bin/python3.10 -m pip install --upgrade pip
|
1 2 3 4 5 6 7 8
| #No module named ‘_ctypes’ sudo apt-get install libffi-dev #No module named '_bz2' ❯ find /usr -type f -name _bz2*.so cp /usr/lib/python3.11/lib-dynload/_bz2.cpython-311-x86_64-linux-gnu.so /home/cs/stable-diffusion-webui/venv/lib/python3.10/site-packages/_bz2.cpython-310-x86_64-linux-gnu.so
# gradio==3.32.0 pip install httpx==0.23.3
|
1 2 3
| cs@debian:~/oss/typoraCracker$ sudo apt-get install python3-pip cs@debian:~/oss/typoraCracker$ pip3 -V pip 20.3.4 from /usr/local/lib/python3.5/dist-packages/pip (python 3.5)
|
升级
1 2 3 4 5 6 7 8
| cs@debian:~/oss/typoraCracker$ sudo pip3 install --upgrade pip Collecting pip Downloading http://mirrors.aliyun.com/pypi/packages/27/79/8a850fe3496446ff0d584327ae44e7500daf6764ca1a382d2d02789accf7/pip-20.3.4-py2.py3-none-any.whl (1.5MB) 100% |████████████████████████████████| 1.5MB 5.8MB/s Installing collected packages: pip Found existing installation: pip 9.0.1 Not uninstalling pip at /usr/lib/python3/dist-packages, outside environment /usr Successfully installed pip-20.3.4
|
国内源
1 2 3 4 5
| https://pypi.doubanio.com/simple/豆瓣 https://mirrors.aliyun.com/pypi/simple/ 阿里 https://mirrors.bfsu.edu.cn/pypi/web/simple/ 中国科学技术大学 https://pypi.tuna.tsinghua.edu.cn/simple/ 清华大学
|
设置 set
1 2 3
| $ pip config set global.index-url https://mirrors.aliyun.com/pypi/simple/ Writing to ~/.config/pip/pip.conf
|
pip.ini
1 2 3 4 5 6
| [global] timeout = 6000 index-url = https://mirrors.aliyun.com/pypi/simple extra-index-url = https://pypi.mirrors.ustc.edu.cn/simple/https://mirrors.aliyun.com/pypi/simple/https://pypi.tuna.tsinghua.edu.cn/simple/http://pypi.mirrors.ustc.edu.cn/simple/https://pypi.org/simple/ [install] trusted-host = pypi.mirrors.ustc.edu.cnpypi.mirrors.ustc.edu.cnmirrors.aliyun.compypi.tuna.tsinghua.edu.cnpypi.mirrors.ustc.edu.cnpypi.org
|
extra-index-url 备用
trusted-host此参数是为了避免麻烦,否则使用的时候可能会提示不受信任
查看 lsit
1 2 3 4 5 6 7 8
| ❯ pip config list freeze.timeout='10' global.extra-index-url='https://pypi.mirrors.ustc.edu.cn/simple/\nhttps://mirrors.aliyun.com/pypi/simple/\nhttps://pypi.tuna.tsinghua.edu.cn/simple/' global.index-url='https://mirrors.aliyun.com/pypi/simple' global.timeout='60' global.trusted-host='mirrors.aliyun.com' install.trusted-host='mirrors.aliyun.com\npypi.tuna.tsinghua.edu.cn\npypi.mirrors.ustc.edu.cn'
|
requirement
生成requirement.txt
文件
pipreqs
在命令行中输入pip install pipreqs
,然后进入项目目录,并执行pipreqs --encoding=utf8 --force
命令
freeze
文件包含的包是当前环境所有的包
pip3 freeze > requirements.txt
install
安装 requirements.txt 文件
pip install -r requirements.txt
卸载
1
| sudo apt-get remove python3-pip
|
debian 12
pipx会安装大量的依赖项
1 2 3
| sudo apt install pipx
pipx install torch --include-deps
|
export PATH=$PATH:”/home/xxx/.local/bin”
https://www.yaolong.net/article/pip-externally-managed-environment/
强制删除此警告(不建议)
1 2 3 4 5
| ❯ ls -l /usr/lib/python3.11/EXTERNALLY-MANAGED -rw-r--r-- 1 root root 645 2023年 3月13日 /usr/lib/python3.11/EXTERNALLY-MANAGED ❯ sudo mv /usr/lib/python3.11/EXTERNALLY-MANAGED /usr/lib/python3.11/EXTERNALLY-MANAGED.bak
sudo mv /usr/lib/python3.11/EXTERNALLY-MANAGED.bak /usr/lib/python3.11/EXTERNALLY-MANAGED
|
和之前一样,现在您可以直接运行 pip
创建虚环境
1
| python3 -m venv /home/cs/oss/sd/sd-venv
|
1 2 3 4 5 6 7 8 9
| ❯ python3 -m venv ./venv ❯ . ./venv/bin/activate ❯ pip list Package Version ---------- ------- pip 23.0.1 setuptools 66.1.1 ❯ pip install Flask
|
python setup
1 2
| python setup.py install --record files.txt 记录安装后文件的路径 cat files.txt | xargs rm -rf 删除这些文件
|
点击打赏
会心一笑