pip 相关

  • 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,内容如下:

[global]
index-url = https://pypi.tuna.tsinghua.edu.cn/simple

windows下,直接在user目录中创建一个pip目录,如:C:\Users\xx\pip,新建文件pip.ini,内容如下

[global]
index-url = https://pypi.tuna.tsinghua.edu.cn/simple

pip install 出错

$ 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('\r\n', '\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('\r\n', '\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

出现错误

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,安装成功。

本文参与腾讯云自媒体分享计划,欢迎正在阅读的你也加入,一起分享。

我来说两句

0 条评论
登录 后参与评论

相关文章

  • pip相关操作与可能遇到的问题

    JNingWei
  • Python安装模块出错解决的办法(pip相关的安装)

    然后在cmd进入命令行窗口, 进入ez_setup.py目录,我这里是下载放置在F盘,然后输入命令:python ez_setup.py 系统就会自动下载se...

    bear_fish
  • windows下python中pip与easy_install相关

    下载地址:https://pypi.python.org/pypi/ez_setup

    WindCoder
  • python相关包无法pip时 原

    通常可以直接google “XXX for python3.5”,或者在github中找到对应的python3.5的项目,将对应的.py文件添加到python的...

    晓歌
  • Python -- 关于pip安装Ipy

    小Q:山外青山楼外楼,西湖歌舞几时休;暖风熏得游人醉,只把杭州比汴州。     --林升··题临安邸

    py3study
  • 关于pip 换源的问题

      阿里云 http://mirrors.aliyun.com/pypi/simple/   中国科技大学 https://pypi.mirrors.ust...

    zhengzongwei
  • CMD终端关于pip报错,scrapy报

    如果在终端输入pip,或scrapy,报如下错误: Fatal error in launcher: Unable to create process usin...

    py3study
  • SASS相关

    版权声明:本文为吴孔云博客原创文章,转载请注明出处并带上链接,谢谢。 https://blog.csdn.net/wkyseo/articl...

    空空云
  • Mysql相关

    我有个同学最近在学Mysql数据库,为了测试自己的学习成果,他们老大出了6道Mysql试题让他去做,晚上回来他又分享给我,我感觉非常经典,记录了这几道试题已及...

    bear_fish
  • Django 相关

    Web框架本质   其实所有的Web应用本质就是一个socket服务端,而用户的浏览器就是一个socket客户端。简单的socket代码如下: import s...

    新人小试
  • Redis相关

      在主从复制的Master和Slave双方都会各自维持一个offset。Master成功发送N个字节的命令后会将Master的offset加上N,Slave在...

    大学里的混子
  • JVM相关

    https://blog.csdn.net/soonfly/article/details/70147205

    大学里的混子
  • Git相关

    洋仔聊编程
  • EF相关

    指尖改变世界
  • JSON相关

    对象表示为键值对 "age" : 10 数据逗号分隔 花括号保存对象 方括号保存数组

    祝你万事顺利
  • QQ相关

    闻语博客
  • TextView相关

    To add the ReadMoreTextView library to your Android Studio project, simply add t...

    用户3004328
  • WebSocket相关

    新人小试
  • gps相关

    1、JavaScript版:通过两个gps坐标计算两点之间实际距离(因为考虑到地球的半径,准确度还行) 其实是直接把这篇文章的java版改成js版而已

    黒之染

扫码关注云+社区

领取腾讯云代金券