Python踩坑之路-Python-3.6 安装pycrypto 2.6.1各种疑难杂症及解决方案

Python踩坑之路-Python-3.6 安装pycrypto 2.6.1各种疑难杂症及解决方案最近接触公司后台管理系统的开发 其中涉及到加密模块 pycrypto 重点来了 敲黑板 pycrypto 在 PyCharm 中跟其他的模块不一样 pipinstallpy 安装的是 1 4 1 版本 然后虽然模块能够 install 成功 但实际上代码还是无法关联起来 运行会报异常 百度解决方案 下载 pycrypto 源码安装不过安装 pycrypto 源码可不是这么简单的事情

2020/3/11更新

========================================================================================================================

1.下载pycrypto源码

python setup.py install 

如果没有报错误,看到

running install_egg_info 

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

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

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

  • VC++2015
  • Python Tools
  • Web Deveolper Tools
    这三个模块,500M左右,重新安装就提示全部成功了
    很多人说装完之后要改环境变量,




 python2:set VS90COMNTOOLS=%VS140COMNTOOLS% python3:set VS100COMNTOOLS=%VS140COMNTOOLS% 
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 

然后代码运行报错,点进去AES里面import的是

from Crypto.Cipher import _AES 
版权声明:本文内容由互联网用户自发贡献,该文观点仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请联系我们举报,一经查实,本站将立刻删除。

发布者:全栈程序员-站长,转载请注明出处:https://javaforall.net/207216.html原文链接:https://javaforall.net

(0)
上一篇 2026年3月19日 下午2:19
下一篇 2026年3月19日 下午2:19


相关推荐

  • javabean总结

    javabean总结

    2021年11月30日
    43
  • CListCtrl自绘「建议收藏」

    CListCtrl自绘「建议收藏」CListCtrl自绘有3种方法:第一种:使用WM_ERASEBKGND消息+NM_CUSTOMDRAW消息配合自绘WM_ERASEBKGND消息中绘制背景色,比如偶数行为灰色,奇数行为白色。NM_CUSTOMDRAW消息中设置字体的背景色和字体颜色。好处:保留了控件大多数的原有属性。不需要自己去输出每一个项目的字体。可以非常方便的设置背景色,以及文字的颜色。缺点:不能设置选中

    2022年6月23日
    41
  • vue的双向绑定原理及实现_vue的数据绑定怎么实现

    vue的双向绑定原理及实现_vue的数据绑定怎么实现vue双向绑定原理浅析1、什么是双向绑定?​ 所谓双向绑定,指的是vue实例中的data与其渲染的DOM元素的内容保持一致,无论谁被改变,另一方会相应的更新为相同的数据。(数据变化更新视图,视图变化更新数据)2、如何实现双向绑定?在vue中可以通过v-model实现双向绑定<template><divid=”app”>{{username}}<br/><inputtype=”text”v-model=”username”&

    2022年10月18日
    4
  • Docker Compose搭建mycat读写分离

    Docker Compose搭建mycat读写分离接上篇docker-compose部署mysql主从复制,本文介绍如何搭建mycat中间件,并用mycat来做读写分离.配置文件以及文档地址:mycat-rw系统环境docker1.12.3mysql5.7.17deepin15.3桌面版(这个没啥影响,因为我们用docker)mycat1.6要点说明看上篇文章的详细介绍暴露mysqlmycat端口号,方便管理本文直接从dock

    2022年10月10日
    3
  • android studio java和xml_android studio闪退

    android studio java和xml_android studio闪退Program:         $JDKPath$\bin\javah.exeParameters:      -classpath$OutputPath$;$ModuleSdkPath$/platforms/android-25/android.jar-jni-d$ModuleFileDir$/src/main/jni$FileClass$

    2026年3月4日
    5
  • Vuthink正确安装过程

    Vuthink正确安装过程

    2021年10月11日
    47

发表回复

您的邮箱地址不会被公开。 必填项已用 * 标注

关注全栈程序员社区公众号