Microsoft Windows Python-3.6 PyCrypto 安装错误
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/41843266/
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
Microsoft Windows Python-3.6 PyCrypto installation error
提问by user1602
pip install pycrypto
works fine with python3.5.2 but fails wiht python3.6 with the following error:
pip install pycrypto
在 python3.5.2 上工作正常,但在 python3.6 上失败并出现以下错误:
inttypes.h(26): error C2061: syntax error: identifier 'intmax_t'
inttypes.h(26):错误 C2061:语法错误:标识符“intmax_t”
回答by user1602
The file include\pyport.h in Python installation directory does not have #include < stdint.h >anymore. This leaves intmax_tundefined.
Python安装目录下的include\pyport.h文件不再有#include <stdint.h>。这使得intmax_t未定义。
A workaround for Microsoft VC compiler is to force include stdint.hvia OS environment variable CL:
Microsoft VC 编译器的解决方法是通过操作系统环境变量CL强制包含stdint.h:
- Open command prompt
- Setup VC environment by runing vcvars*.bat (choose file name depending on VC version and architecture)
- set CL=-FI"Full-Path\stdint.h" (use real value for Full-Path for the environment)
- pip install pycrypto
- 打开命令提示符
- 通过运行 vcvars*.bat 设置 VC 环境(根据 VC 版本和架构选择文件名)
- 设置 CL=-FI"Full-Path\stdint.h"(使用环境的 Full-Path 的真实值)
- pip 安装 pycrypto
回答by Marko Rothstein
I've succeeded install pycrypto 2.6.1 on python 3.6, Windows 10, Visual Studio 2017.
我已成功在 python 3.6、Windows 10、Visual Studio 2017 上安装 pycrypto 2.6.1。
- open "x86_x64 Cross-Tools Command Prompt for VS 2017" with administrator privilege in start menu.
- set CL=-FI"%VCINSTALLDIR%Tools\MSVC\14.11.25503\include\stdint.h"
- pip install pycrypto
- 在开始菜单中以管理员权限打开“x86_x64 Cross-Tools Command Prompt for VS 2017”。
- 设置 CL=-FI"%VCINSTALLDIR%Tools\MSVC\14.11.25503\include\stdint.h"
- pip 安装 pycrypto
回答by naaman
Thanks to user1960422's answer.
PowerShell steps for pycrypto 2.6.1 (via simple-crypt) / Python 3.6 / Windows 10:
感谢user1960422的回答。
pycrypto 2.6.1(通过 simple-crypt)/Python 3.6/Windows 10 的 PowerShell 步骤:
$env:VCINSTALLDIR="C:\Program Files (x86)\Microsoft Visual Studio 14.0\VC"
$env:CL="-FI`"$env:VCINSTALLDIR\INCLUDE\stdint.h`""
Successful simple-crypt / pycrypto install
成功的 simple-crypt / pycrypto 安装
I also needed to follow the answer in: https://stackoverflow.com/a/24822876/8751739to fix a winrandom
module error.
我还需要按照以下答案进行操作:https: //stackoverflow.com/a/24822876/8751739以修复winrandom
模块错误。
回答by bhuvan karuturi
Use PyCryptodomeinstead of pycrypto. pycrypto is discontinuedand is no longer actively supported. PyCryptodome exposes almost the same API as pycrypto (source).
使用PyCryptodome而不是pycrypto。pycrypto 已停产,不再受到积极支持。PyCryptodome 公开了与 pycrypto 几乎相同的 API(源代码)。
回答by user1960422
I've succeeded install pycrypo 2.6.1 on python 3.6 and windows 10.
我已经成功地在 python 3.6 和 windows 10 上安装了 pycrypo 2.6.1。
- Set an environment variable like below.
- Open cmd.exe
- Activate virtualenv
- Download pycrypto 2.6.1 release from github and unzip it.
- set an environment variable for pycrypto
set CL=/FI"%VCINSTALLDIR%\\INCLUDE\\stdint.h" %CL%
- Run setup command
python setup.py install
- my result is here
- 设置一个环境变量,如下所示。
- 打开cmd.exe
- 激活虚拟环境
- 从 github 下载 pycrypto 2.6.1 版本并解压。
- 为 pycrypto 设置环境变量
set CL=/FI"%VCINSTALLDIR%\\INCLUDE\\stdint.h" %CL%
- 运行设置命令
python setup.py install
- 我的结果在这里
I would be glad if this could be help someone.
如果这可以帮助某人,我会很高兴。
回答by Sebastian Duran
Uninstall your current Python version
Install Python for amd64 architecture
Follow the other accepted solutions
- open "x86_x64 Cross-Tools Command Prompt for VS 2017"
- Add the new enviroment varible for your Visual Studio MSVC install path
set CL=-FI"%VCINSTALLDIR%Tools\MSVC\14.11.25503\include\stdint.h"
pip install pycrypto
卸载当前的 Python 版本
为 amd64 架构安装 Python
遵循其他公认的解决方案
- 打开“用于 VS 2017 的 x86_x64 跨工具命令提示符”
- 为 Visual Studio MSVC 安装路径添加新的环境变量
set CL=-FI"%VCINSTALLDIR%Tools\MSVC\14.11.25503\include\stdint.h"
pip install pycrypto
回答by Jee Mok
For me this fixes it:
对我来说,这修复了它:
with Python 2, I have
使用 Python 2,我有
sudo apt-get install python-dev \
build-essential libssl-dev libffi-dev \
libxml2-dev libxslt1-dev zlib1g-dev \
...
with Python 3, I need
使用 Python 3,我需要
sudo apt-get install python3 python-dev python3-dev \
build-essential libssl-dev libffi-dev \
...
Installing python-dev python3-dev
fixes it for me!
安装python-dev python3-dev
为我修复它!