python 3.5上的PyCrypto
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/32800336/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
PyCrypto on python 3.5
提问by Trsak
I found some PyCrypto installers for Python 3.3 and 3.4, but nothing for Python 3.5.
我找到了一些适用于 Python 3.3 和 3.4 的 PyCrypto 安装程序,但没有适用于 Python 3.5。
When I try to install PyCrypton using pip install
, it says:
当我尝试使用 安装 PyCrypton 时pip install
,它说:
warning: GMP or MPIR library not found; Not building Crypto.PublicKey._fastmath.
Is there any way to install PyCrypto on Python 3.5 in Windows 10? Thanks!
有没有办法在 Windows 10 的 Python 3.5 上安装 PyCrypto?谢谢!
采纳答案by sfbahr
That warning shouldn't stop the build, more likely you are lacking the Visual Studio 2015 compiler which is necessary to build binary extensions (which PyCrypto has). See the Python Packaging User Guidefor which compiler you need for your version of Python.
该警告不应停止构建,更有可能的是您缺少构建二进制扩展(PyCrypto 具有)所必需的 Visual Studio 2015 编译器。请参阅Python Packaging User Guide,了解您的 Python 版本所需的编译器。
The reason you need the compiler is PyCrypto only offers a Source Distribution officially. So, you have two options for installing PyCrypto:
您需要编译器的原因是 PyCrypto 仅正式提供源代码分发。因此,您有两种安装 PyCrypto 的选项:
1. Build from source:
1. 从源代码构建:
This is actually fairly simple, but it requires that you install some extra software. Again, refer to the Python Packaging User Guide linked above to find the suitable compiler for your version of Python. I think that there is an option to only install the relevant compiler for Python if you do a custom install of Visual Studio.
这实际上相当简单,但它需要您安装一些额外的软件。同样,请参阅上面链接的 Python 打包用户指南,以找到适合您的 Python 版本的编译器。我认为如果您进行 Visual Studio 的自定义安装,则可以选择仅安装 Python 的相关编译器。
Then, after the installation is completed, and you probably had to restart your computer, you should be able to simply run pip install pycrypto
and pip will download the source and compile it for you.
然后,安装完成后,您可能必须重新启动计算机,您应该可以简单地运行pip install pycrypto
,pip 会下载源代码并为您编译。
If you also installed wheel (pip install wheel
) then pip will create a wheel from the source and cache it, which is how I created the wheels that I'm sharing in option 2.
如果您还安装了轮子 ( pip install wheel
),那么 pip 将从源创建一个轮子并将其缓存,这就是我创建我在选项 2 中共享的轮子的方式。
2. Install a Built Distribution from a 3rd party
2. 从 3rd 方安装内置发行版
I happen to be a 3rd party and have shared wheels I compiled for PyCrypto 2.6.1 w/ Python 3.5 for 32 and 64-bit Windows on my GitHub repo. I included installation instructions on the readme of that repo.
我碰巧是第 3 方,并且在我的 GitHub 存储库上共享了我为 PyCrypto 2.6.1 w/ Python 3.5 for 32 and 64-bit Windows 编译的轮子。我在该 repo 的自述文件中包含了安装说明。
If you're looking for a built distribution for an older version of Python and/or PyCrypto, I've also linked to Voidspace on my repo's readme (sorry, I'm limited to 2 links here).
如果您正在为旧版本的 Python 和/或 PyCrypto 寻找内置发行版,我还在我的 repo 的自述文件中链接到了 Voidspace(抱歉,我在这里仅限于 2 个链接)。
回答by SquareRootOfTwentyThree
You can try PyCryptodome, a fork of PyCrypto. It has Windows wheels for Python 3.5.
您可以尝试PyCryptodom,它是 PyCrypto 的一个分支。它具有适用于 Python 3.5 的 Windows 轮子。
回答by andhdo
Use this post as a reference to do this procedure over Windows systems: http://codeyarns.com/2012/04/28/python-version-not-found-in-registry-error/
使用这篇文章作为在 Windows 系统上执行此过程的参考:http: //codeyarns.com/2012/04/28/python-version-not-found-in-registry-error/
Using that, we can do this:
使用它,我们可以这样做:
- Using the Windows Run dialog, open the
regedit
program. - Export from
HKEY_LOCAL_MACHINE\SOFTWARE\Python
(python_install_35.reg). Go to this location and execute "export" in the context menu. - Edit the reg file and replace
HKEY_LOCAL_MACHINE
withHKEY_CURRENT_USER
- Execute a console (cmd) prompt as admin and execute
regedit python_install_35.reg
- Add the entries to the registry
- See the modified entries with regedit and change
HKEY_CURRENT_USER\SOFTWARE\Python\PythonCore\3.5
toHKEY_CURRENT_USER\SOFTWARE\Python\PythonCore\3.3
. - Re-run the installer
- 使用 Windows 运行对话框打开
regedit
程序。 - 从
HKEY_LOCAL_MACHINE\SOFTWARE\Python
(python_install_35.reg)导出。转到此位置并在上下文菜单中执行“导出”。 - 编辑reg文件并替换
HKEY_LOCAL_MACHINE
为HKEY_CURRENT_USER
- 以管理员身份执行控制台 (cmd) 提示并执行
regedit python_install_35.reg
- 将条目添加到注册表
- 使用 regedit 查看修改后的条目并更改
HKEY_CURRENT_USER\SOFTWARE\Python\PythonCore\3.5
为HKEY_CURRENT_USER\SOFTWARE\Python\PythonCore\3.3
。 - 重新运行安装程序
回答by SvennnG
Use pycryptodomeinstead! It is a project still maintained (june 2017) and includes the functions of pycrypto for python 3.xx (It worked for me on python 3.6)
改用pycryptodome吧!这是一个仍在维护的项目(2017 年 6 月),包括用于 python 3.xx 的 pycrypto 功能(它在 python 3.6 上对我有用)
Project Page:
项目页面: