Python-3.6 安装pycrypto 2.6

1.下载pycrypto源码

官网:https://www.dlitz.net/software/pycrypto/ 
github:https://github.com/dlitz/pycrypto 
下载源码解压,win+R运行cmd,进入解压文件夹

python setup.py install
  • 1

如果没有报错误,看到

running install_egg_info
  • 1

恭喜你,不用踩坑,直接可以关闭这篇东西去愉快地写代码了

2.安装过程中显示unable to find vcvarsall.bat

这是window环境下安装模块比较常见的问题,这时候你百度的话大部分文章就会告诉你下载vs,python2的话安装vs2010,python3的话安装vs2013 。

vs的版本号对应关系如下: 

msvs2005版本号为8.0,对应环境变量VS80COMNTOOLS 
msvs2008版本号为9.0,对应环境变量VS90COMNTOOLS 
msvs2010版本号为10.0,对应环境变量VS100COMNTOOLS 
msvs2012版本号为11.0,对应环境变量VS110COMNTOOLS 
msvs2013版本号为12.0,对应环境变量VS120COMNTOOLS 
msvs2015版本号为14.0,对应环境变量VS140COMNTOOLS

3.安装对应版本的msvs(Microsoft Visual Studio)

如果是Visual Studio 2015,提供个百度经验上百度网盘给大家 
http://pan.baidu.com/s/1eSueWLG 
如果不需要用vs进行开发的话,装community免费版就可以了,没必要纠结专业版啥的 
安装过程中要注意,建议安装的时候选自定义(截图来自百度经验,因为已经安装了打开之后有点不太一样) 
这里写图片描述 

  • VC++2015
  • Python Tools
  • Web Deveolper Tools 
    这三个模块,500M左右,重新安装就提示全部成功了 
    很多人说装完之后要改环境变量,
 python2:set VS90COMNTOOLS=%VS140COMNTOOLS%
 python3:set VS100COMNTOOLS=%VS140COMNTOOLS%
  • 1
  • 2

可能python3.6版本高了不需要这样,不过也记录一下给各位看官仅供参考。反正我是不需要改,因为接下来我踩了另一个坑 
再次进入pycryto的解压文件夹python setup.py install 仍然显示 
building ‘Crypto.Random.OSRNG.winrandom‘ extension

running install
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
C:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\BIN\x86_amd64\cl.exe /c /nologo /Ox /W3 /GL /DNDEBUG /MD -Isrc/ -Isrc/inc-msvc/ -IC:\Python36\include -IC:\Python36\include
winrand.c
C:\Program Files (x86)\Windows Kits\10\include\10.0.10240.0\ucrt\inttypes.h(26): error C2061: syntax error: identifier ‘intmax_t‘
C:\Program Files (x86)\Windows Kits\10\include\10.0.10240.0\ucrt\inttypes.h(27): error C2061: syntax error: identifier ‘rem‘
C:\Program Files (x86)\Windows Kits\10\include\10.0.10240.0\ucrt\inttypes.h(27): error C2059: syntax error: ‘;‘
C:\Program Files (x86)\Windows Kits\10\include\10.0.10240.0\ucrt\inttypes.h(28): error C2059: syntax error: ‘}‘
C:\Program Files (x86)\Windows Kits\10\include\10.0.10240.0\ucrt\inttypes.h(30): error C2061: syntax error: identifier ‘imaxdiv_t‘
C:\Program Files (x86)\Windows Kits\10\include\10.0.10240.0\ucrt\inttypes.h(30): error C2059: syntax error: ‘;‘
C:\Program Files (x86)\Windows Kits\10\include\10.0.10240.0\ucrt\inttypes.h(40): error C2143: syntax error: missing ‘{‘ before ‘__cdecl‘
C:\Program Files (x86)\Windows Kits\10\include\10.0.10240.0\ucrt\inttypes.h(41): error C2146: syntax error: missing ‘)‘ before identifier ‘_Number‘
C:\Program Files (x86)\Windows Kits\10\include\10.0.10240.0\ucrt\inttypes.h(41): error C2061: syntax error: identifier ‘_Number‘
C:\Program Files (x86)\Windows Kits\10\include\10.0.10240.0\ucrt\inttypes.h(41): error C2059: syntax error: ‘;‘
C:\Program Files (x86)\Windows Kits\10\include\10.0.10240.0\ucrt\inttypes.h(42): error C2059: syntax error: ‘)‘
C:\Program Files (x86)\Windows Kits\10\include\10.0.10240.0\ucrt\inttypes.h(45): error C2143: syntax error: missing ‘{‘ before ‘__cdecl‘
C:\Program Files (x86)\Windows Kits\10\include\10.0.10240.0\ucrt\inttypes.h(46): error C2146: syntax error: missing ‘)‘ before identifier ‘_Numerator‘
C:\Program Files (x86)\Windows Kits\10\include\10.0.10240.0\ucrt\inttypes.h(46): error C2061: syntax error: identifier ‘_Numerator‘
C:\Program Files (x86)\Windows Kits\10\include\10.0.10240.0\ucrt\inttypes.h(46): error C2059: syntax error: ‘;‘
C:\Program Files (x86)\Windows Kits\10\include\10.0.10240.0\ucrt\inttypes.h(46): error C2059: syntax error: ‘,‘
C:\Program Files (x86)\Windows Kits\10\include\10.0.10240.0\ucrt\inttypes.h(48): error C2059: syntax error: ‘)‘
C:\Program Files (x86)\Windows Kits\10\include\10.0.10240.0\ucrt\inttypes.h(50): error C2143: syntax error: missing ‘{‘ before ‘__cdecl‘
C:\Program Files (x86)\Windows Kits\10\include\10.0.10240.0\ucrt\inttypes.h(56): error C2143: syntax error: missing ‘{‘ before ‘__cdecl‘
C:\Program Files (x86)\Windows Kits\10\include\10.0.10240.0\ucrt\inttypes.h(63): error C2143: syntax error: missing ‘{‘ before ‘__cdecl‘
C:\Program Files (x86)\Windows Kits\10\include\10.0.10240.0\ucrt\inttypes.h(69): error C2143: syntax error: missing ‘{‘ before ‘__cdecl‘
C:\Program Files (x86)\Windows Kits\10\include\10.0.10240.0\ucrt\inttypes.h(76): error C2143: syntax error: missing ‘{‘ before ‘__cdecl‘
C:\Program Files (x86)\Windows Kits\10\include\10.0.10240.0\ucrt\inttypes.h(82): error C2143: syntax error: missing ‘{‘ before ‘__cdecl‘
C:\Program Files (x86)\Windows Kits\10\include\10.0.10240.0\ucrt\inttypes.h(89): error C2143: syntax error: missing ‘{‘ before ‘__cdecl‘
C:\Program Files (x86)\Windows Kits\10\include\10.0.10240.0\ucrt\inttypes.h(95): error C2143: syntax error: missing ‘{‘ before ‘__cdecl‘
error: command ‘C:\\Program Files (x86)\\Microsoft Visual Studio 14.0\\VC\\BIN\\x86_amd64\\cl.exe‘ failed with exit status 2
  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
  • 8
  • 9
  • 10
  • 11
  • 12
  • 13
  • 14
  • 15
  • 16
  • 17
  • 18
  • 19
  • 20
  • 21
  • 22
  • 23
  • 24
  • 25
  • 26
  • 27
  • 28
  • 29
  • 30
  • 31
  • 32
  • 33
  • 34

4.解决building ‘Crypto.Random.OSRNG.winrandom‘ extension

1.添加VC环境变量,设置用户环境变量,这里划重点!!!是用户环境变量,不是系统环境变量 
这里写图片描述 
变量名:VCINSTALLDIR 
(变量值为vs安装路径下的VC,默认是这个) 
变量值:C:\Program Files (x86)\Microsoft Visual Studio 14.0\VC 
2. win+R运行cmd,执行命令set CL=/FI”%VCINSTALLDIR%\INCLUDE\stdint.h” %CL% 
3. 再次进入pycryto的解压文件夹python setup.py install ,看到这里写图片描述 

能显示running install_egg_info 就是安装成功了

如果不行的话,可以右键以管理员运行。

原文转自:https://blog.csdn.net/a624806998/article/details/78596543

  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
### 回答1: 要安装Python 3.8的pycrypto模块,可以按照以下步骤进行操作: 1. 确认已经安装Python 3.8版本,可以在命令行中输入python --version进行确认。 2. 安装pip工具,可以在命令行中输入python -m ensurepip进行安装。 3. 使用pip工具安装pycrypto模块,可以在命令行中输入pip install pycrypto进行安装。 4. 安装完成后,可以在Python代码中使用import Crypto来引入pycrypto模块。 需要注意的是,pycrypto模块已经停止维护,建议使用cryptography模块代替。 ### 回答2: 在安装 Python 3.8 时,默认情况下 PYCrypto 并不包含在 Python 3.8 的主要库中,需要额外下载安装。以下为 Python 3.8 安装 PYCrypto 的步骤: 1. 安装 Microsoft Visual Studio C++ Build Tools 因为 PYCrypto 是一个基于 C 的库,所以需要先安装适合您操作系统版本的 Microsoft Visual Studio C++ Build Tools。您可以从 Microsoft Visual Studio 网站下载安装据此步骤: - 在 Microsoft Visual Studio 下载页面中,从“工作负载”菜单中选择“C++ Build Tools”。 - 选择适合您操作系统版本的 C++ Build Tools 下载链接。 - 执行下载安装过程中出现的任何提示。 2. 安装 PYCrypto 可以通过以下方式安装 PYCrypto: - 打开您的命令窗口(Windows)或终端(Linux/MacOS)。 - 使用以下命令安装 PYCrypto: pip install pycrypto 3. 验证 PYCrypto 安装 完成 PYCrypto 安装之后,您可以使用以下命令验证该库是否已正确安装: - 打开您的 Python 解释器。 - 输入以下代码并按下 Enter: import Crypto - 如果代码成功运行且未显示任何错误消息,则 PYCrypto 库已成功安装完毕。 总之,安装 PYCrypto 需要两个步骤,先安装 Microsoft Visual Studio C++ Build Tools,然后再使用 pip 安装 PYCrypto。完成之后,您可以使用 Python 解释器验证该库是否已正确安装。需要注意的是,PYCryptoPython 3.8 中已停止支持,推荐使用 PyCryptodome 代替它进行加密解密操作。 ### 回答3: Python是一种流行的编程语言,具有易用性和生成高质量代码的能力,而pycryptoPython中用于加密和解密数据的流行软件包。在Python 3.8中,pycrypto软件包的安装可能与以前的版本不同。下面是一个详细的安装指南。 1.安装依赖项 在安装pycrypto之前,您需要安装一些依赖项。打开终端并键入以下命令: ``` sudo apt install build-essential libssl-dev libffi-dev python3-dev ``` 这将安装构建必备的gcc、make、openssl和libffi-dev包以及Python开发库。 2.下载pycrypto软件包 可以从Python Package Index(PyPI)下载最新版本的pycrypto。 打开终端并输入以下命令: ``` pip install pycrypto ``` 如果您的系统上安装了多个Python版本,则必须使用pip3来下载软件包: ``` pip3 install pycrypto ``` 在某些情况下,您可能还需要安装依赖的软件包,如setuptools和wheel: ``` pip install wheel setuptools pycrypto ``` 3.测试安装 安装完成后,请尝试导入pycrypto软件包以测试是否已成功安装。 打开Python交互模式并输入以下代码: ``` >>> import Crypto ``` 如果您没有遇到任何错误,则表示pycrypto已成功安装。 在Python 3.8中,pycrypto安装可能与早期版本不同,但遵循上述步骤可以确保成功地安装和使用该软件包。此外,我们建议您始终使用最新版本的软件包,并根据需要升级现有的软件包。
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值