- Ubuntu 14.04
pip 使用国内镜像源
使用pip install 的时候总是出现read timeout 之类的错误
使用国内镜像 https://pypi.tuna.tsinghua.edu.cn/simple
例如我要安装 scrapy
pip install -i https://pypi.tuna.tsinghua.edu.cn/simple scrapy
添加源的配置
Linux下,修改 ~/.pip/pip.conf (没有就创建一个), 修改 index-url至tuna,内容如下:
代码语言:javascript复制[global]
index-url = https://pypi.tuna.tsinghua.edu.cn/simple
windows下,直接在user目录中创建一个pip目录,如:C:Usersxxpip,新建文件pip.ini,内容如下
代码语言:javascript复制[global]
index-url = https://pypi.tuna.tsinghua.edu.cn/simple
pip install
出错
代码语言:javascript复制$ pip install pycairo
Collecting pycairo
Downloading https://files.pythonhosted.org/packages/e8/9d/c8be300fc6b1298559d37a071c3833b0b251e0fff334d2e4c408d5789162/pycairo-1.19.1.tar.gz (205kB)
100% |████████████████████████████████| 215kB 644kB/s
Installing collected packages: pycairo
Running setup.py install for pycairo ... error
Complete output from command /Users/rustfisher/Desktop/intGo/studySR/venv/bin/python -u -c "import setuptools, tokenize;__file__='/private/var/folders/ds/b1cvbdm97dz7bynp0xzr3f7c0000gn/T/pip-install-jhvl5plj/pycairo/setup.py';f=getattr(tokenize, 'open', open)(__file__);code=f.read().replace('rn', 'n');f.close();exec(compile(code, __file__, 'exec'))" install --record /private/var/folders/ds/b1cvbdm97dz7bynp0xzr3f7c0000gn/T/pip-record-dqg8zbp0/install-record.txt --single-version-externally-managed --compile --install-headers /Users/rustfisher/Desktop/intGo/studySR/venv/include/site/python3.7/pycairo:
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
[Errno 20] Not a directory: 'pkg-config'
----------------------------------------
Command "/Users/rustfisher/Desktop/intGo/studySR/venv/bin/python -u -c "import setuptools, tokenize;__file__='/private/var/folders/ds/b1cvbdm97dz7bynp0xzr3f7c0000gn/T/pip-install-jhvl5plj/pycairo/setup.py';f=getattr(tokenize, 'open', open)(__file__);code=f.read().replace('rn', 'n');f.close();exec(compile(code, __file__, 'exec'))" install --record /private/var/folders/ds/b1cvbdm97dz7bynp0xzr3f7c0000gn/T/pip-record-dqg8zbp0/install-record.txt --single-version-externally-managed --compile --install-headers /Users/rustfisher/Desktop/intGo/studySR/venv/include/site/python3.7/pycairo" failed with error code 1 in /private/var/folders/ds/b1cvbdm97dz7bynp0xzr3f7c0000gn/T/pip-install-jhvl5plj/pycairo/
You are using pip version 10.0.1, however version 20.2.2 is available.
You should consider upgrading via the 'pip install --upgrade pip' command.
用brew安装pkg-config
$ 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
。
出现错误
代码语言:javascript复制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(‘“‘“‘rn’”‘“‘, ‘“‘“‘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(‘“‘“‘rn’”‘“‘, ‘“‘“‘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
,安装成功。