python 安装库pycrypto失败的一系列问题[已解决]

这篇具有很好参考价值的文章主要介绍了python 安装库pycrypto失败的一系列问题[已解决]。希望对大家有所帮助。如果存在错误或未考虑完全的地方,请大家不吝赐教,您也可以点击"举报违法"按钮提交疑问。

需要安装pycrypto这个库。

/*****************安装pycryptodome***********************/

说来难受,后面发现这个貌似不再维护了,可以安装另外一个库pycryptodome,是这个库的延伸版本,和这个库的作用是一样的,我也是看别人的。
安装pycryptodome

pip install pycryptodome
/*****************安装pycryptodome***********************/

安装pycrypto

需要安装pycrypto的继续:注意3.9以上版本的python可能都无法使用。存在一个错误。

  File "c:\Users\ice\Desktop\112.py", line 7, in <module>
    cipher = AES.new(key, AES.MODE_ECB)
             ^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "D:\software\compiler\python\python3.11.5\Lib\site-packages\Crypto\Cipher\AES.py", line 95, in new
    return AESCipher(key, *args, **kwargs)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "D:\software\compiler\python\python3.11.5\Lib\site-packages\Crypto\Cipher\AES.py", line 59, in __init__
    blockalgo.BlockAlgo.__init__(self, _AES, key, *args, **kwargs)
  File "D:\software\compiler\python\python3.11.5\Lib\site-packages\Crypto\Cipher\blockalgo.py", line 141, in __init__
    self._cipher = factory.new(key, *args, **kwargs)
                   ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
SystemError: PY_SSIZE_T_CLEAN macro must be defined for '#' formats

目前知道是要加宏定义

Note For all # variants of formats (s#, y#, etc.), the macro PY_SSIZE_T_CLEAN must be defined before including Python.h. On Python 3.9 and older, the type of the length argument is Py_ssize_t if the PY_SSIZE_T_CLEAN macro is defined, or int otherwise.

但是还没有测试,不知道要怎么加。

python3.8版本测试是可以使用的。python3.8版本以下都可以使用。
应该是不兼容。python3.9以上版本,需要有定义
继续安装 pycrypto

pip install pycrypto

但是直接安装就会出现错误如下:

Building wheels for collected packages: pycrypto
  Building wheel for pycrypto (pyproject.toml) ... error
  error: subprocess-exited-with-error

  × Building wheel for pycrypto (pyproject.toml) did not run successfully.exit code: 1
  ╰─> [2 lines of output]
      warning: GMP or MPIR library not found; Not building Crypto.PublicKey._fastmath.
      error: Microsoft Visual C++ 14.0 or greater is required. Get it with "Microsoft C++ Build Tools": https://visualstudio.microsoft.com/visual-cpp-build-tools/
      [end of output]

  note: This error originates from a subprocess, and is likely not a problem with pip.
  ERROR: Failed building wheel for pycrypto
Failed to build pycrypto
ERROR: Could not build wheels for pycrypto, which is required to install pyproject.toml-based projects

error: Microsoft Visual C++ 14.0 or greater is required. Get it with “Microsoft C++ Build Tools”: https://visualstudio.microsoft.com/visual-cpp-build-tools/

这说需要一个C++ 14.0以上的版本
https://visualstudio.microsoft.com/visual-cpp-build-tools/
去这个网址下载一个安装工具

error: could not build wheels for pycrypto, which is required to install pyp,python,python,visual studio

下载后直接运行安装

error: could not build wheels for pycrypto, which is required to install pyp,python,python,visual studio
在下载过程中还可以确认一个东西,但是实际上只要下载了python版本都自己带有,不管是老版本还是新版本,3.8,3.11亲测都有,这个东西就是setuptools。这个的版本应该和python安装的时间有关,安装早的版本可能会老一点。
安装这个c++编译器 Microsoft Visual C++ ,需要有配对的setuptools版本。
安装最新的Microsoft Visual C++,需要配备最新的setuptools。(实践证明较新的也可以,估测60版本以上都可以)

Microsoft Visual C++ 14.2 standalone: Build Tools for Visual Studio 2019 (x86, x64, ARM, ARM64)
This is a standalone version of Visual C++ 14.2 compiler, you don't need to install Visual Studio 2019.

In Build tools, install C++ build tools and ensure the latest versions of MSVCv142 - VS 2019 C++ x64/x86 build tools and Windows 10 SDK are checked.
The setuptools Python package version must be at least 34.4.0.

安装Visual C++ 14.2 compiler版本的需要setuptools至少34.4.0。
详细版本对应可以参考Visual C++ 14.2 compiler对应版本

查看setuptools版本的方法。

>>> import setuptools
>>> print(setuptools._version__)
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
AttributeError: module 'setuptools' has no attribute '_version__'. Did you mean: '__version__'?
>>> print(setuptools.__version__)
65.5.0

我查了3.8和3.11的python,版本差别不大的,都是高版本(11:68)。我的是65版本,可以直接安装最新的Visual C++ 14.3。(setuptools的版本应该和python版本关系不大,和python的安装时间有关,大家可以查看自己的版本,在65以上必然就可以安装最新的)

安装好后会出现如下界面:

error: could not build wheels for pycrypto, which is required to install pyp,python,python,visual studio
选中使用C++的桌面开发这个即可,然后右边有默认选项,会默认选了五个,后两个可以不用选,不会有影响,但是选上也没占多少内存。建议默认选项即可。
最好是默认,默认可以成果,其他的可能存在错误(选低版本的SDK和编译器会报错)
另外这里要注意选的是windows 11 SDK,这个无论你是window10的系统还是window11的系统都可以安装,亲测有效,win7其他的就不清楚了。
同时还可以修改安装位置,安装这个编译器包括这个window11SDK,总共大小有接近6G,可以换到其他盘进行安装,同时也可以取消勾选保留下载缓存。
error: could not build wheels for pycrypto, which is required to install pyp,python,python,visual studio
下载安装需要一定时间,不需要连到外网也可以下载。

error: could not build wheels for pycrypto, which is required to install pyp,python,python,visual studio
安装好后继续输入:

pip install pycrypto

发现会有另外一个错误。

error: could not build wheels for pycrypto, which is required to install pyp,python,python,visual studio

 C:\Program Files (x86)\Windows Kits\10\include\10.0.22621.0\ucrt\inttypes.h(31): error C2061: 语法错误: 标识符“intmax_t”

提示这个文件存在语法错误。标识符错误,这个变量类型错误。

参考这篇文章解决的。
https://blog.csdn.net/miffy2017may/article/details/107546033
方法如下:
1、找到你刚刚下载的编译器保存的文件位置。

C:\Program Files (x86)\Microsoft Visual Studio\2022\BuildTools\VC\Tools\MSVC\14.39.33519\include

默认是这个路径,可能版本区别,路径会有些许区别,但也可以找到。

2、找到这个路径下的一个文件stdint.h,复制该文件
error: could not build wheels for pycrypto, which is required to install pyp,python,python,visual studio
3、找到另外一个文件夹C:\Program Files (x86)\Windows Kits\10\Include\10.0.22621.0\ucrt
这个文件夹,大家都有的,将上一步复制的stdint.h复制到这个文件夹下。

4、编辑该文件夹下的inttypes.h文件,记事本打开即可

error: could not build wheels for pycrypto, which is required to install pyp,python,python,visual studio
5、修改文件中的#include <stdint.h>,为 #include “stdint.h”,就是把尖括号改为双引号。涉及c头文件读取方面的问题。

error: could not build wheels for pycrypto, which is required to install pyp,python,python,visual studio
完成上面步骤,再次运行命令 pip install pycrypto

error: could not build wheels for pycrypto, which is required to install pyp,python,python,visual studio
这样就成功安装pycrypto

貌似没用了,都2024年了,用pycryptodome吧。
安装pycryptodome

pip install pycryptodome

这是注定一个悲剧的晚上,以此篇注定无人问津的文章哀悼。文章来源地址https://www.toymoban.com/news/detail-845242.html

到了这里,关于python 安装库pycrypto失败的一系列问题[已解决]的文章就介绍完了。如果您还想了解更多内容,请在右上角搜索TOY模板网以前的文章或继续浏览下面的相关文章,希望大家以后多多支持TOY模板网!

本文来自互联网用户投稿,该文观点仅代表作者本人,不代表本站立场。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如若转载,请注明出处: 如若内容造成侵权/违法违规/事实不符,请点击违法举报进行投诉反馈,一经查实,立即删除!

领支付宝红包 赞助服务器费用

相关文章

  • 如何解决python安装mysqlclient失败问题

    在使用Django等框架来操作MySQL时,实际上底层还是通过Python来操作的,首先需要安装一个驱动程序,在Python3中,驱动程序有多种选择,比如有pymysql以及mysqlclient等。使用pip命令安装mysqlclient失败应如何解决?   机器同时安装了python2和python3版本,以安装的Python 3.7.0 (32 bit)为例

    2024年03月27日
    浏览(44)
  • 安装fasttext的一系列问题(全)

    环境配置:windows10+python3.10 前言:Gensim中的fasttext不能做文本分类,对于想学习fasttext进行文本分类、情感分析的同学还是必须下载Facebook的fasttext 在该python libs (或者粘贴该链接https://www.lfd.uci.edu/~gohlke/pythonlibs/#fasttext)搜索fasttext 下载whl文件,文件名: fasttext-0.9.2-cp310-cp31

    2024年02月06日
    浏览(45)
  • 阿里云弹性云桌面安装失败问题解决记录(.net framework 4.6.2 or later:Error Code: 12029)

    1,问题 图像显示客户端安装错误     然后我就手动下载了,这个文件 下载好之后是这个文件     然后安装一下就报了这个错误 .net framework 4.6.2 or later:Error Code: 12029 这个问题是.net framework 4.6.2文件有问题,把他重新安装就好了 然后又发现.net framework 4.6.2安装不了 解决了这个

    2024年02月06日
    浏览(31)
  • 安装node-sass失败 或 npm install Error: not found: python2 解决方案

    1. 安装python2 可以用npm命令安装 也可以自行下载安装 Python 2.7 2. 安装完毕后配置环境变量 3.再配置一下版本 node-sass 实在太坑了,之前遇到安装失败使用方法一完美解决。最近又一次遇到了,但是方法一又无效了。于是我又在网上找到另一个方法,就是用 dart-sass 来替换 node

    2024年02月13日
    浏览(57)
  • Python + selenium 安装问题,pip install selenium失败及解决方法

              最近想要是使用Python 访问下浏览器,网上关于这些东西都很多,Python 安装和 selenium 的下载就不赘述,这里简单总结一下第一次安装Python + selenium中遇到的问题。     Python傻瓜式安装,但注意 安装目录选择 , 环境变量的添加 。     selenium.exe下载对应浏览器对应

    2024年02月11日
    浏览(44)
  • RabbitMQ启动失败的一系列尝试

    在三台 CentOS 7.x上部署了RabbitMQ集群,如下:  服务器IP hostname 节点说明 端口 管控台地址 192.168.31.101 master rabbitmq master 5672 http://192.168.11.71:15672 192.168.31.102 slave1 rabbitmq slave 5672 http://192.168.11.72:15672 192.168.31.103 slave2 rabbitmq slave 5672 http://192.168.11.73:15672 集群部署教程可参考:Rabb

    2024年02月04日
    浏览(25)
  • 由ImportError: No module named openpyxl引发的一系列python问题

    场景描述 如下是我在运行python文件时出现的一系列问题,没有和我一样问题的,大家可以找自己对应的问题,不需要一点一点看,谢谢大家。 问题1:运行py文件出现ImportError: No module named openpyxl错误 在执行某个python文件时,出现了该错误,是因为没有相关模块造成的。 解决方

    2024年02月02日
    浏览(31)
  • 解决yolov5运行环境——pycocotools >= 2.0 安装失败问题 error: Microsoft Visual C++ 14.0 or greater is required. error: Microsoft Visual C++ 14.0 or greater is required.

    在使用pip install pycocotools 安装时总是失败 当出现该问题时,本人尝试去百度上搜索相关的解决方案,尝试了好多方法还是安装失败,失败的尝试如下: 尝试1: 安装Microsoft Visual C++ Build Tools 2015              显示安装包都是丢失或损坏,然后本人就去寻找别的版本的M

    2024年02月05日
    浏览(42)
  • Win解答 | 解决键盘中 字母+空格 导致的输入法弹窗导致的一系列问题

    近三个月来,一直都有一个键盘组合键的问题影响我的电脑使用,不管是打字还是打游戏,都会出现按键盘的 字母+空格 弹出一个特殊符号的候选框,如下图所示 图片中为 S+空格 所出现的弹窗 一个看似方便,实则难受的功能 其实打字写代码的时候还好,只是速度快的时候关

    2024年02月10日
    浏览(24)
  • 解决Visual C++2008安装失败,error 1935

    重装系统后Visual C++没了,其他都能装上但VC2008会报这个error 1935。 鉴于我把网上所有的解决方法排了一遍错,我也不知道是哪一步起效,所以就都放上来了。 特别注意:报error 1935的错误原因可能不尽相同,比如我的报错开头为An error occurred,结尾为HRESULT:0x80070005。 80070005

    2024年02月15日
    浏览(44)

觉得文章有用就打赏一下文章作者

支付宝扫一扫打赏

博客赞助

微信扫一扫打赏

请作者喝杯咖啡吧~博客赞助

支付宝扫一扫领取红包,优惠每天领

二维码1

领取红包

二维码2

领红包