pip 安装问题的一些解决办法
·
有时候出现安装必须要用它所指向的官方源时,并且手里还不能翻墙工具时,会出现很多依赖的、比较"大"的包需要安装,但网络速度太慢,安装很费劲
现在给出一个比较适合的办法:就是在安装的时候,看它依赖什么,自己再去换源安装
例如在安装ultralytics时
pip install ultralytics
会出现需要安装opencv
root@ubuntu:/# pip install ultralytics
Collecting ultralytics
Using cached ultralytics-8.3.203-py3-none-any.whl (1.1 MB)
Collecting opencv-python>=4.6.0
Downloading opencv_python-4.12.0.88-cp37-abi3-manylinux2014_aarch64.manylinux_2_17_aarch64.whl (45.9 MB)
^C
ERROR: Operation cancelled by user
用官方源安装,网络太慢,可以换做豆瓣源:
-i https://pypi.douban.com/simple/
安装命令如下:
pip install 'opencv-python>=4.6.0' -i https://pypi.douban.com/simple/
注意,不是pip install opencv-python>=4.6.0 -i https://pypi.douban.com/simple/。
而是pip install ‘opencv-python>=4.6.0’ -i https://pypi.douban.com/simple/。上面那种方式有时候是安装不了的,在某些 shell 环境下,> 可能会被当作 重定向符号,导致命令解析错误。 虽然能跑,但它不是完全符合规范的写法
当出现如下错误时
ERROR: Command errored out with exit status 1:
command: /usr/bin/python3 /usr/lib/python3/dist-packages/pip install --ignore-installed --no-user --prefix /tmp/pip-build-env-nldb_66q/normal --no-warn-script-location --no-binary :none: --only-binary :none: -i https://pypi.tuna.tsinghua.edu.cn/simple -- puccinialin
cwd: None Complete output (3 lines): Looking in indexes: https://pypi.tuna.tsinghua.edu.cn/simple
ERROR: Could not find a version that satisfies the requirement puccinialin (from versions: none) ERROR: No matching distribution found for puccinialin ----------------------------------------
ERROR: Command errored out with exit status 1: /usr/bin/python3 /usr/lib/python3/dist-packages/pip install --ignore-installed --no-user --prefix /tmp/pip-build-env-nldb_66q/normal --no-warn-script-location --no-binary :none: --only-binary :none: -i https://pypi.tuna.tsinghua.edu.cn/simple -- puccinialin Check the logs for full command output.
表示的是pip环境有污染。处理办法
python3 -m pip install --upgrade pip setuptools wheel # 升级pip setuptools wheel
然后重新安装
pip install 'polars' -i https://pypi.tuna.tsinghua.edu.cn/simple --no-cache-dir
更多推荐



所有评论(0)