Python-3.6 安装pycrypto 2.6
最近接触公司后台管理系统的开发,其中涉及到加密模块pycrypto。
重点来了!!!!敲黑板!!!!
pycrypto在PyCharm中跟其他的模块不一样,pip install pycrypto安装的是1.4.1版本,然后虽然模块能够install成功,但实际上代码还是无法关联起来,运行会报异常。
百度解决方案:下载pycrypto源码安装
不过安装pycrypto源码可不是这么简单的事情,这里把这几天踩过的坑都记录一下。
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,这东西一安装就是好几个小时,在这里我对vs装了卸,卸了装浪费了一天半的时间。
python有个深坑!不同的python版本对应不同的vs版本,具体对应的版本在python所在的路径下\Lib\distutils_msvccompiler.py
比如我的路径是E:\Python\Python36\Lib\distutils_msvccompiler.py
打开找到def _find_vcvarsall(plat_spec)
这个函数下有个if version >= 14 and version > best_version
这里的version >= 14就是对应的vs版本号,如果你跟我一样是python3.6的话应该这里是14,之前就是看到其他的博客,没有查看这里的版本号就装,先是装了vs2010,然后装2013,再卸了装了对应版本号的vs2015,其中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的话最好也勾上吧。
但我的安装过程没这么顺利,泪奔~
安装部分模块失败,然后我重新安装。因为主要的vs2015安装是成功的,所以只勾选
- 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
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 就是安装成功了
5.注意是Crypto还是crypto,区分大小写
我这里安装成功之后代码alt+enter自动关联的是
from crypto.Cipher import AES
- 1
然后代码运行报错,点进去AES里面import的是
from Crypto.Cipher import _AES
- 1
小伙伴如果遇到跟我一样的问题,可以手动进入python\Lib下,我的路径是
E:\Python\Python36\Lib
然后把文件夹crypto改成Crypto。把小写改成大写,刷新下,完美运行~~~~
转自:https://blog.csdn.net/a624806998/article/details/78596543?utm_source=copy
Python-3.6 安装pycrypto 2.6的更多相关文章
- 转:python安装pycrypto
from: http://ljhzzyx.blog.163.com/blog/static/3838031220136592824697/ 在windows下用一下开源工具就是悲催,如题pytho ...
- python在windows下安装paramiko模块和安装pycrypto模块(3步搞定)(转)
Python中使用SSH需要用到OpenSSH,而OpenSSH依赖于paramiko模块,而paramiko模块又依赖于pycrypto模块,因此要在Python中使用SSH,我们需要先安装pycr ...
- python安装pycrypto库
使用pycharm时安装pycrypto库,一直安装不上,提示安装成功,退出去一看,依旧没有 最后选择了pip安装,但一直报错(Microsoft Visual C++ 9.0 is required ...
- python安装pycrypto报错error: command 'x86_64-linux-gnu-gcc' failed with exit status 1
系统3.19.0-15-generic #15-Ubuntu 安装pycrypto提示error: command 'x86_64-linux-gnu-gcc' failed with exit st ...
- pip安装pycrypto报错:Microsoft Visual C++ 14.0 is required. 和 SSLError: HTTPSConnectionPool的解决办法
今天本打算把[Python3爬虫]网易云音乐爬虫 的代码敲一遍, 但是在安装pycrypto老是报错, 由于我计算是win10, 并且也有vs2017 python3环境下安装pycrypto的一些问 ...
- Windows安装pycrypto失败记录
Windows 10家庭中文版,Python 3.6.4, 180824测试前端加密文本在后台揭秘,查询后发现,可以使用pycrypto模块实现,那么,安装它(pip),结果安装失败了. 本文暂时记录 ...
- 解决win764位安装pycrypto遇到unable to find vcvarsall.bat 问题
今天安装pycrypto的库.安装中遇到一些问题,这里简单记录下来. 首先安装python,pycrypto是基于python的一个库. 第一种:搜索关键字pycrypto,找到pycrypto的官方 ...
- python3.5安装pycrypto
在python中使用AES加密是一种有效的加密方式,如果你研究过微信公众号api就会发现,它也用的是这个加密的.在写代码的时候,要安装crypto模块,在linux或者mac上都好说,但是在windo ...
- [ Python - 15 ] win7安装paramiko问题总汇
安装环境: win7 sp1 python3.5 安装paramiko 新装的win7 sp1 x64位系统,安装好python3.5和pycharm后,需要用到paramiko模块于是开始安装: & ...
随机推荐
- GetSystemMetrics()函数的用法 转
转自 http://www.cnblogs.com/lidabo/archive/2012/07/10/2584725.html 可以用GetSystemMetrics函数可以获取系统分辨率,但这只是 ...
- IE下页面左偏移并页头空出一行解决方法
在其它浏览器下显示正常,包括360浏览器,在IE下,页面向左偏移,通过firebug查看,head标签为空,并且head标签里面的内容都跑到body标签内了,原因是有bom头,访问的页面或是加载,包含 ...
- MyBatis之Mapper XML 文件详解(二)-sql和入参
sql 这个元素可以被用来定义可重用的 SQL 代码段,可以包含在其他语句中.它可以被静态地(在加载参数) 参数化. 不同的属性值通过包含的实例变化. 比如: <sql id="use ...
- JAVA中时间格式转换
1.将任意日期格式的字符串转换为指定格式的字符串 //默认格式 String s1 = "20190110133236"; //给定格式 String s2 = "201 ...
- 由Oracle 11g SYSAUX 和 SYSTEM 表空间回收引发的联想
0x00--目的 整理一下以前一个SYSTEM表空间和SYSAUX表空间使用率达到99%上限的处理思路和相关知识点,好记性不如烂笔头 0x01--表空间使用率现状 通过查询可得知目前表空间使用情况如下 ...
- C++笔记009:C++对C的扩展——“实用性”增加
原创笔记,转载请注明出处! 点击[关注],关注也是一种美德~ 笔记八中已经说到:在 C语言中定义了3个层次的作用域,即文件(编译单元).函数和复合语句. C语言中的变量都必须在作用域开始的位置定义! ...
- SQL语句中生成UUID方法
SQL语句中生成UUID方法为UUID() 生成带横线UUID: select UUID() 形如:abaffaca-fd55-11e5-b3d0-d2 ...
- java 计算器算法脚本
import javax.script.ScriptEngine; import javax.script.ScriptEngineManager; public String Count(Strin ...
- [异常笔记] zookeeper集群启动异常: Cannot open channel to 2 at election address ……
- ::, [myid:] - WARN [WorkerSender[myid=]:QuorumCnxManager@] - Cannot open channel to at election ad ...
- 集合之HashMap、Hashtable
HashMap 基于哈希表的 Map 接口的实现.此实现提供所有可选的映射操作,并允许使用 null 值和 null 键.(除了非同步和允许使用 null 之外,HashMap 类与 Hashtabl ...