V2EX = way to explore
V2EX 是一个关于分享和探索的地方
现在注册
已注册用户请  登录
推荐学习书目
Learn Python the Hard Way
Python Sites
PyPI - Python Package Index
http://diveintopython.org/toc/index.html
Pocoo
值得关注的项目
PyPy
Celery
Jinja2
Read the Docs
gevent
pyenv
virtualenv
Stackless Python
Beautiful Soup
结巴中文分词
Green Unicorn
Sentry
Shovel
Pyflakes
pytest
Python 编程
pep8 Checker
Styles
PEP 8
Google Python Style Guide
Code Style from The Hitchhiker's Guide
raiz
V2EX  ›  Python

windows python3 安装 pycrypto 库遇到麻烦, 是不是要安装 vs?

  •  
  •   raiz · 2015-10-04 12:12:06 +08:00 · 4840 次点击
    这是一个创建于 3136 天前的主题,其中的信息可能已经有所发展或是发生改变。

    xxx\pycrypto-2.6.1>python34 setup.py build
    running build
    running build_py
    running build_ext
    warning: GMP or MPIR library not found; Not building Crypto.PublicKey._fastmath.
    building 'Crypto.Random.OSRNG.winrandom' extension
    Traceback (most recent call last):
    File "setup.py", line 456, in <module>
    core.setup(**kw)
    File "C:\Python34\lib\distutils\core.py", line 148, in setup
    dist.run_commands()
    File "C:\Python34\lib\distutils\dist.py", line 955, in run_commands
    self.run_command(cmd)
    File "C:\Python34\lib\distutils\dist.py", line 974, in run_command
    cmd_obj.run()
    File "C:\Python34\lib\distutils\command\build.py", line 126, in run
    self.run_command(cmd_name)
    File "C:\Python34\lib\distutils\cmd.py", line 313, in run_command
    self.distribution.run_command(command)
    File "C:\Python34\lib\distutils\dist.py", line 974, in run_command
    cmd_obj.run()
    File "setup.py", line 253, in run
    build_ext.run(self)
    File "C:\Python34\lib\distutils\command\build_ext.py", line 339, in run
    self.build_extensions()
    File "setup.py", line 150, in build_extensions
    build_ext.build_extensions(self)
    File "C:\Python34\lib\distutils\command\build_ext.py", line 448, in build_extensions
    self.build_extension(ext)
    File "C:\Python34\lib\distutils\command\build_ext.py", line 503, in build_extension
    depends=ext.depends)
    File "C:\Python34\lib\distutils\msvc9compiler.py", line 460, in compile
    self.initialize()
    File "C:\Python34\lib\distutils\msvc9compiler.py", line 371, in initialize
    vc_env = query_vcvarsall(VERSION, plat_spec)
    File "C:\Python34\lib\distutils\msvc9compiler.py", line 287, in query_vcvarsall
    raise ValueError(str(list(result.keys())))
    ValueError: ['path']

    11 条回复    2015-10-05 08:58:01 +08:00
    FrankFang128
        1
    FrankFang128  
       2015-10-04 12:14:01 +08:00 via Android
    装个 Ubuntu
    zhuangzhuang1988
        2
    zhuangzhuang1988  
       2015-10-04 12:32:06 +08:00
    vs 有个专门的针对 python 的编译器
    geeklian
        3
    geeklian  
       2015-10-04 12:38:11 +08:00
    1 楼简直呵呵了...v2er 现在就这水准了?

    方法 1 :按个 Visual Studio 2010 ,以后就继续 pip 。

    方法 2 :使用 anaconda3.4 代替原版的 python3.4 , anaconda 是一个 cpython 的打包发行版,优点 NumPy\pycrypto 这种很难装的 pkg 都非常简单的安装。

    方法 3 :打开 http://www.voidspace.org.uk/python/pycrypto-2.6.1/,下载 pycrypto-2.6.1.win-amd64-py3.4.msi 。就单个包来说...收藏 2 个网址

    http://www.lfd.uci.edu/~gohlke/pythonlibs/
    http://www.voidspace.org.uk/python/modules.shtml
    RAKE
        4
    RAKE  
       2015-10-04 13:02:06 +08:00
    没记错那个 VS For Python 下载链接是 http://aka.ms/vspython

    的确有种 Python 在 Linux 下的支持更好的错觉了。蛮多 Python 开发的个人小应用到 Windows 就水土不服。尤其是中文支持!
    geeklian
        5
    geeklian  
       2015-10-04 13:51:00 +08:00
    @RAKE


    Python version VC++ version
    2.5.6 7.1
    2.6.9 9.0
    2.7.6 9.0
    3.2.3 9.0
    3.3.5 10.0
    3.4.0 10.0

    9.0 = 2008
    10.0 = 2010

    3.5.0 要用 Visual Studio Community 2015 编译...

    python 的情况比微软想的还复杂... 233...

    微软给的 Microsoft Visual C++ Compiler for Python 2.7 ,这货其实是 vc2008 的编译环境,最好不要用在 python3.4 上

    但扯到各种第三方库的代码在不同版本的 vc 下不一定都能编译过去...

    所以最好的办法,还是下载现成的编译打包版本
    raiz
        6
    raiz  
    OP
       2015-10-04 14:38:28 +08:00
    @geeklian 谢谢 我用方法 3 直接安装了二进制
    raiz
        7
    raiz  
    OP
       2015-10-04 14:40:50 +08:00
    @geeklian 谢谢 好详细 python 在 windows 下 真蛋疼
    asahi
        8
    asahi  
       2015-10-04 14:49:02 +08:00
    这个问题我也遇到过,后来直接安了二进制包。 stackoverflow 上有一个回答能完整解决问题,需要安装 vs2010 还有一些补丁包,有些麻烦,但安装好就一劳永逸了。
    RAKE
        9
    RAKE  
       2015-10-04 22:54:59 +08:00
    @geeklian 果然我记错了, http://aka.ms/vcpython27 的确是 2.7 的 pip 弹出来的。
    还有比较想知道为何少部分库要自行编译, ruby 也是。
    raiz
        10
    raiz  
    OP
       2015-10-04 23:03:16 +08:00
    @RAKE 也想问, 版本很多很乱
    QQ1685425675
        11
    QQ1685425675  
       2015-10-05 08:58:01 +08:00
    有时候 安装一个 mingw32 也行的 加入系统变量
    关于   ·   帮助文档   ·   博客   ·   API   ·   FAQ   ·   我们的愿景   ·   实用小工具   ·   2288 人在线   最高记录 6543   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 26ms · UTC 04:32 · PVG 12:32 · LAX 21:32 · JFK 00:32
    Developed with CodeLauncher
    ♥ Do have faith in what you're doing.