pip 相关
本文最后更新于:2023年4月15日 下午
- Ubuntu 14.04
pip 使用国内镜像源
使用pip install 的时候总是出现read timeout 之类的错误
使用国内镜像 https://pypi.tuna.tsinghua.edu.cn/simple
例如我要安装 scrapy1
pip install -i https://pypi.tuna.tsinghua.edu.cn/simple scrapy
添加源的配置
Linux下,修改 ~/.pip/pip.conf (没有就创建一个), 修改 index-url至tuna,内容如下:1
2[global]
index-url = https://pypi.tuna.tsinghua.edu.cn/simple
windows下,直接在user目录中创建一个pip目录,如:C:\Users\xx\pip,新建文件pip.ini,内容如下1
2[global]
index-url = https://pypi.tuna.tsinghua.edu.cn/simple
pip install
出错
1 |
|
用brew安装pkg-config
1
2
3
4
5 $ brew install pkg-config
==> Downloading https://mirrors.ustc.edu.cn/homebrew-bottles/bottles/pkg-config-0.29.2_3.mojave.bottle.tar.g
######################################################################## 100.0%
==> Pouring pkg-config-0.29.2_3.mojave.bottle.tar.gz
🍺 /usr/local/Cellar/pkg-config/0.29.2_3: 11 files, 623.6KB
然后再运行pip install pycairo
。
出现错误
Collecting pycairo
Using cached pycairo-1.19.1.tar.gz (205 kB)
Using legacy setup.py install for pycairo, since package ‘wheel’ is not installed.
Installing collected packages: pycairo
Running setup.py install for pycairo … error
ERROR: Command errored out with exit status 1:
command: /Library/Frameworks/Python.framework/Versions/3.7/bin/python3.7 -u -c ‘import sys, setuptools, tokenize; sys.argv[0] = ‘“‘“‘/private/var/folders/ds/b1cvbdm97dz7bynp0xzr3f7c0000gn/T/pip-install-_fvz20yx/pycairo/setup.py’”‘“‘; file=’”‘“‘/private/var/folders/ds/b1cvbdm97dz7bynp0xzr3f7c0000gn/T/pip-install-_fvz20yx/pycairo/setup.py’”‘“‘;f=getattr(tokenize, ‘“‘“‘open’”‘“‘, open)(file);code=f.read().replace(‘“‘“‘\r\n’”‘“‘, ‘“‘“‘\n’”‘“‘);f.close();exec(compile(code, file, ‘“‘“‘exec’”‘“‘))’ install –record /private/var/folders/ds/b1cvbdm97dz7bynp0xzr3f7c0000gn/T/pip-record-0xkj4in4/install-record.txt –single-version-externally-managed –compile –install-headers /Library/Frameworks/Python.framework/Versions/3.7/include/python3.7m/pycairo
cwd: /private/var/folders/ds/b1cvbdm97dz7bynp0xzr3f7c0000gn/T/pip-install-_fvz20yx/pycairo/
Complete output (15 lines):
running install
running build
running build_py
creating build
creating build/lib.macosx-10.9-x86_64-3.7
creating build/lib.macosx-10.9-x86_64-3.7/cairo
copying cairo/init.py -> build/lib.macosx-10.9-x86_64-3.7/cairo
copying cairo/init.pyi -> build/lib.macosx-10.9-x86_64-3.7/cairo
copying cairo/py.typed -> build/lib.macosx-10.9-x86_64-3.7/cairo
running build_ext
Package cairo was not found in the pkg-config search path.
Perhaps you should add the directory containing `cairo.pc’
to the PKG_CONFIG_PATH environment variable
No package ‘cairo’ found
Command '['pkg-config', '--print-errors', '--exists', 'cairo >= 1.13.1']' returned non-zero exit status 1.
----------------------------------------
ERROR: Command errored out with exit status 1: /Library/Frameworks/Python.framework/Versions/3.7/bin/python3.7 -u -c ‘import sys, setuptools, tokenize; sys.argv[0] = ‘“‘“‘/private/var/folders/ds/b1cvbdm97dz7bynp0xzr3f7c0000gn/T/pip-install-_fvz20yx/pycairo/setup.py’”‘“‘; file=’”‘“‘/private/var/folders/ds/b1cvbdm97dz7bynp0xzr3f7c0000gn/T/pip-install-_fvz20yx/pycairo/setup.py’”‘“‘;f=getattr(tokenize, ‘“‘“‘open’”‘“‘, open)(file);code=f.read().replace(‘“‘“‘\r\n’”‘“‘, ‘“‘“‘\n’”‘“‘);f.close();exec(compile(code, file, ‘“‘“‘exec’”‘“‘))’ install –record /private/var/folders/ds/b1cvbdm97dz7bynp0xzr3f7c0000gn/T/pip-record-0xkj4in4/install-record.txt –single-version-externally-managed –compile –install-headers /Library/Frameworks/Python.framework/Versions/3.7/include/python3.7m/pycairo Check the logs for full command output.
执行brew install cairo pkg-config freetype harfbuzz
,把这几个包安装一下。
然后再pip install pycairo
,安装成功。