网站建设岗位需要解决的问题/数据分析网官网
发布Flask Web项目时,报错缺少Cryptography,于是尝试重新安装该库,但本机没有网络,只支持手动离线安装,尝试了pip、setup.py两种方式安装,结果都报错。。最后使用将安装包拷贝至本机(在其他电脑上安装的sitepackages里面的文件),重启后发现可以读取到该库
报错:RuntimeErrorRuntimeError: 'cryptography' package is required for sha256_password or caching_sha2_password auth methodsTraceback (most recent call last)· File "E:\software\python\lib\site-packages\flask\app.py", line 2213, in __call__return self.wsgi_app(environ, start_response)· File "E:\software\python\lib\site-packages\flask\app.py", line 2193, in wsgi_appresponse = self.handle_exception(e)· File "E:\software\python\lib\site-packages\flask\app.py", line 2190, in wsgi_appresponse = self.full_dispatch_request()· File "E:\software\python\lib\site-packages\flask\app.py", line 1486, in full_dispatch_requestrv = self.handle_user_exception(e)· File "E:\software\python\lib\site-packages\flask\app.py", line 1484, in full_dispatch_requestrv = self.dispatch_request()· File "E:\software\python\lib\site-packages\flask\app.py", line 1469, in dispatch_requestreturn self.ensure_sync(self.view_functions[rule.endpoint])(**view_args)· File "E:\projects\WEB\HR_DL_DATA\hrproject\hrproject\V0809.01\app.py", line 7, in my_echartconn1, cur1 = utils.get_conn()· File "E:\projects\WEB\HR_DL_DATA\hrproject\hrproject\V0809.01\utils.py", line 8, in get_connconn = pymysql.connect(host='127.0.0.1',· File "E:\software\python\lib\site-packages\pymysql\connections.py", line 352, in __init__self.connect()· File "E:\software\python\lib\site-packages\pymysql\connections.py", line 636, in connectself._request_authentication()· File "E:\software\python\lib\site-packages\pymysql\connections.py", line 933, in _request_authenticationauth_packet = _auth.caching_sha2_password_auth(self, auth_packet)· File "E:\software\python\lib\site-packages\pymysql\_auth.py", line 265, in caching_sha2_password_authdata = sha2_rsa_encrypt(conn.password, conn.salt, conn.server_public_key)· File "E:\software\python\lib\site-packages\pymysql\_auth.py", line 143, in sha2_rsa_encryptraise RuntimeError(RuntimeError: 'cryptography' package is required for sha256_password or caching_sha2_password auth methodsThe debugger caught an exception in your WSGI application. You can now look at the traceback which led to the error.To switch between the interactive traceback and the plaintext one, you can click on the "Traceback" headline. From the text traceback you can also create a paste of it. For code execution mouse-over the frame you want to debug and click on the console icon on the right side.You can execute arbitrary Python code in the stack frames and there are some extra helpers available for introspection:· dump() shows all variables in the frame· dump(obj) dumps all that's known about the object
这个报错提示是由于在您的项目中使用了 pymysql
库,而该库需要依赖 cryptography
来支持 sha256_password
或 caching_sha2_password
身份验证方法。由于您当前的环境中缺少 cryptography
包,所以导致了这个报错。
为了解决这个问题,您可以考虑以下几种方法:
-
手动安装 cryptography 包: 尝试手动从源代码构建并安装
cryptography
包,如前面所述。这将为pymysql
提供所需的支持。 -
尝试其他 MySQL 连接库: 如果您只是为了连接 MySQL 数据库,您也可以尝试使用其他的 MySQL 连接库,例如
mysql-connector-python
,它可能不需要cryptography
依赖。 -
等待更新: 如前所述,您也可以等待
cryptography
更新并发布适用于您的配置的版本。
无论您选择哪种方法,都需要确保您的项目中安装了所需的依赖库,并且根据需要更新或调整代码以适应新的库版本。
cryptography需要单独安装吗?
是的,cryptography
包需要单独安装。它不是Python的内置标准库,因此需要使用 pip
命令来安装。
您可以使用以下命令来安装 cryptography
包:
pip install cryptography
安装完成后,您的项目应该就能够正常使用 pymysql
库并支持 sha256_password
或 caching_sha2_password
身份验证方法了。这将解决您之前报错的问题。
如果您没有网络连接,无法直接使用 pip
安装 cryptography
包,您可以从另一台有网络连接的计算机上下载 cryptography
包的安装文件(whl 文件),然后将其传输到您的目标计算机进行安装。
以下是具体步骤:
- 在有网络连接的计算机上,使用以下命令下载
cryptography
包的安装文件:
pip download cryptography
-
这将会下载
cryptography
包及其依赖的安装文件到当前目录。将下载得到的.whl
文件复制到您的目标计算机上。 -
在目标计算机上,使用以下命令进行安装(假设您将
.whl
文件放在了同一个文件夹内):
pip install cryptography-3.3.2-cp36-abi3-win_amd64.whl
请注意,上述命令中的 .whl
文件名可能与您下载的文件名略有不同,您需要根据实际文件名进行调整。
通过这种方式,您可以将 cryptography
包的安装文件从有网络连接的计算机传输到目标计算机上,从而在没有网络连接的情况下进行安装。
我能直接把cryptography、cryptography-3.3.2.dist-info复制到sitepackages吗?
是的,您可以尝试将 cryptography
包及其相关的 .dist-info
文件夹复制到 Python 的 site-packages
目录中。这种方法有时可以在没有网络连接的情况下手动安装包。
请按照以下步骤操作:
-
从另一台有网络连接的计算机上下载
cryptography
包的.whl
安装文件和.dist-info
文件夹。确保您下载的是适用于您的 Python 版本和操作系统的版本。 -
将这些文件复制到目标计算机上。您可以将
cryptography
包的.whl
文件和.dist-info
文件夹一起复制到目标计算机上的 Python 的site-packages
目录中。 -
打开命令行窗口,并导航到 Python 安装目录的
Scripts
文件夹中(例如:E:\software\python\Scripts
)。 -
在命令行中运行以下命令来重新生成安装包的元数据缓存:
python -m ensurepip
-
然后,尝试在命令行中运行您的应用程序,看看是否成功解决了报错问题。
请注意,尽管这种方法在某些情况下可能有效,但由于包的版本和依赖性问题,可能并不总是适用。在没有网络连接的情况下手动安装包时,请务必备份好您的现有环境,以防止出现意外问题。
如果这些步骤无法解决问题,可能需要尝试其他方法或在有网络连接的环境中进行操作。
我拷贝了cryptography
包及其相关的 .dist-info
文件夹复制到 Python 的 site-packages
目录中,发现还是读取不到这个包
如果您将cryptography
包及其相关的.dist-info
文件夹复制到了Python的site-packages
目录中,但仍然无法读取该包,您可以尝试以下步骤:
-
确保您已经将
cryptography
包及其.dist-info
文件夹复制到了正确的site-packages
目录下。您可以通过运行以下命令来查找Python的site-packages
路径:python -m site
在输出中查找
USER_SITE
和ENABLE_USER_SITE
行,以确定site-packages
的路径。 -
确保复制的文件具有正确的权限。有时,文件权限问题可能会影响包的加载。您可以尝试使用管理员权限复制文件,或者确保复制的文件具有与其他包相同的权限。
-
确保您的Python解释器版本与您从其他计算机下载的
cryptography
包的版本相匹配。如果版本不匹配,可能会出现问题。 -
在将文件复制到
site-packages
目录后,尝试重新生成安装包的元数据缓存。在命令行中运行以下命令:python -m ensurepip
-
重新启动您的Python解释器,然后尝试导入
cryptography
包并运行您的应用程序。
如果您仍然无法解决问题,可能需要考虑其他解决方法,例如尝试使用其他计算机进行安装并将生成的虚拟环境(包括site-packages
目录)复制到您的目标计算机上。另外,您还可以考虑在有网络连接的环境中解决此问题,例如使用代理或移动到网络连接较好的地方进行操作。
重启了电脑可以读取到!!!
其他问题
怎么处理这个问题:Microsoft Windows [版本 10.0.17134.1]
© 2018 Microsoft Corporation。保留所有权利。
E:\software\python\Lib\site-packages\package\cr\cryptography-3.3.2>python setup.py install
E:\software\python\lib\site-packages\setuptools_init_.py:84: _DeprecatedInstaller: setuptools.installer and fetch_build_eggs are deprecated.
!!
********************************************************************************Requirements should be satisfied by a PEP 517 installer.If you are using pip, you can try `pip install --use-pep517`.********************************************************************************
!!
dist.fetch_build_eggs(dist.setup_requires)
WARNING: The wheel package is not available.
running install
E:\software\python\lib\site-packages\setuptools_distutils\cmd.py:66: SetuptoolsDeprecationWarning: setup.py install is deprecated.
!!
********************************************************************************Please avoid running ``setup.py`` directly.Instead, use pypa/build, pypa/installer, pypa/build orother standards-based tools.See https://blog.ganssle.io/articles/2021/10/setup-py-deprecated.html for details.********************************************************************************
!!
self.initialize_options()
E:\software\python\lib\site-packages\setuptools_distutils\cmd.py:66: EasyInstallDeprecationWarning: easy_install command is deprecated.
!!
********************************************************************************Please avoid running ``setup.py`` and ``easy_install``.Instead, use pypa/build, pypa/installer, pypa/build orother standards-based tools.See https://github.com/pypa/setuptools/issues/917 for details.********************************************************************************
!!
self.initialize_options()
running bdist_egg
running egg_info
writing src\cryptography.egg-info\PKG-INFO
writing dependency_links to src\cryptography.egg-info\dependency_links.txt
writing requirements to src\cryptography.egg-info\requires.txt
writing top-level names to src\cryptography.egg-info\top_level.txt
reading manifest file ‘src\cryptography.egg-info\SOURCES.txt’
reading manifest template ‘MANIFEST.in’
no previously-included directories found matching ‘docs_build’
warning: no previously-included files found matching ‘vectors’
warning: no previously-included files matching ‘*’ found under directory ‘vectors’
warning: no previously-included files matching ‘*’ found under directory ‘.github’
warning: no previously-included files found matching ‘release.py’
warning: no previously-included files found matching ‘.coveragerc’
warning: no previously-included files found matching ‘codecov.yml’
warning: no previously-included files found matching ‘.readthedocs.yml’
warning: no previously-included files found matching ‘dev-requirements.txt’
warning: no previously-included files found matching ‘rtd-requirements.txt’
warning: no previously-included files found matching ‘tox.ini’
warning: no previously-included files matching ‘*’ found under directory ‘.zuul.d’
warning: no previously-included files matching ‘*’ found under directory ‘.zuul.playbooks’
adding license file ‘LICENSE’
adding license file ‘LICENSE.APACHE’
adding license file ‘LICENSE.BSD’
adding license file ‘LICENSE.PSF’
adding license file ‘AUTHORS.rst’
writing manifest file ‘src\cryptography.egg-info\SOURCES.txt’
installing library code to build\bdist.win-amd64\egg
running install_lib
running build_py
running build_ext
generating cffi module ‘build\temp.win-amd64-cpython-310\Release\_padding.c’
already up-to-date
generating cffi module ‘build\temp.win-amd64-cpython-310\Release\_openssl.c’
already up-to-date
building ‘_openssl’ extension
=============================DEBUG ASSISTANCE=============================If you are seeing a compilation error please try the following steps tosuccessfully install cryptography:1) Upgrade to the latest pip and try again. This will fix errors for mostusers. See: https://pip.pypa.io/en/stable/installing/#upgrading-pip2) Read https://cryptography.io/en/latest/installation.html for specificinstructions for your platform.3) Check our frequently asked questions for more information:https://cryptography.io/en/latest/faq.html=============================DEBUG ASSISTANCE=============================
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/
E:\software\python\Lib\site-packages\package\cr\cryptography-3.3.2>
解决办法
问题出在你缺少 Microsoft Visual C++ 14.0 或更高版本的编译工具,这是安装 cryptography
包时出现的错误。为了解决这个问题,你需要安装 Microsoft C++ Build Tools。你可以按照以下步骤进行操作:
-
访问链接 https://visualstudio.microsoft.com/visual-cpp-build-tools/,下载并安装 Microsoft Visual C++ 14.0 或更高版本的编译工具。这将为你提供所需的编译环境,使得安装
cryptography
包时能够成功编译相关的 C 扩展。 -
安装完成后,重新运行你的安装命令。你可以使用
pip
命令代替python setup.py install
进行安装,同时添加--use-pep517
参数,以启用 PEP 517 安装程序:pip install . --use-pep517
-
如果上述步骤无法解决问题,你可以尝试执行以下操作:
- 确保你的 Python 环境和安装的包是兼容的,例如确保使用的是与
cryptography
包兼容的 Python 版本。 - 更新你的
pip
版本到最新版本:pip install --upgrade pip
。 - 阅读
cryptography
包的官方安装文档,以获取针对你的操作系统和环境的具体安装指导:https://cryptography.io/en/latest/installation.html。
- 确保你的 Python 环境和安装的包是兼容的,例如确保使用的是与
如果你仍然遇到问题,可以尝试在官方文档中提到的“DEBUG ASSISTANCE”部分提供的调试步骤,这可能会帮助你进一步解决安装问题。
相关文章:

Windows 环境下 Python3 离线安装 cryptography 失败
发布Flask Web项目时,报错缺少Cryptography,于是尝试重新安装该库,但本机没有网络,只支持手动离线安装,尝试了pip、setup.py两种方式安装,结果都报错。。最后使用将安装包拷贝至本机(在其他电脑上安装的sit…...

年轻代频繁GC ParNew导致http变慢
背景介绍 某日下午大约四点多,接到合作方消息,线上环境,我这边维护的某http服务突然大量超时(对方超时时间设置为300ms),我迅速到鹰眼平台开启采样,发现该服务平均QPS到了120左右,平…...

在.NET 6.0中自定义接口路由
在本文中,我们将讨论ASP.NET Core中的新路由。我们将了解什么是接口(endpoints)路由,它是如何工作的,它在哪里使用,以及如何创建自己的路由。 本文主题: 探索接口路由创建自定义接口创建更复杂的接口 名词定义&#…...
Kotlin读写分离CopyOnWriteArrayList
Kotlin读写分离CopyOnWriteArrayList 基于读写分离思想Copy-On-Write(COW)设计的线程安全ArrayList变体,读读共享、写写互斥、读写互斥、写读互斥。读时直接读,不用加锁同步,线程安全。写/删/修改数据时复制一个副本,在新的List副…...

centos自动同步北京时间
1、安装ntpdate服务 yum -y install ntpdate 2、加入自动任务计划 查找ntpdate的路径: which ntpdate 复制这个路径。 编辑自动任务计划并加入ntpdate: crontab -e # 每小时第30分钟同步AD域控时间 30 * * * * /usr/sbin/ntpdate -u 192.168.2.8 > …...

element-ui表格跨页多选实现
前言 在我们日常项目开发中,经常会有表格跨页多选的需求,接下来让我们用 el-table 示例一步步来实现这个需求。 动手开发 在线体验 https://codesandbox.io/s/priceless-mcclintock-4cp7x3?file/src/App.vue 常规版本 本部分只写了一些重点代码,心急的彦祖可以直接看 性…...

线性代数(三) 线性方程组向量空间
前言 如何利用行列式,矩阵求解线性方程组。 线性方程组的相关概念 用矩阵方程表示 齐次线性方程组:Ax0;非齐次线性方程组:Axb. 可以理解 齐次线性方程组 是特殊的 非齐次线性方程组 如何判断线性方程组的解 其中R(A)表示矩阵A的…...

学习跨度级交互以提取方面情感三元组
方面情感三元组 方面情感三元组(Aspect Sentiment Triplet)是一种在情感分析中使用的结构,它包含三个部分:方面目标(Aspect Target)、情感(Sentiment)和对应的观点词(Op…...

那些年的Xposed开发经验记录
把之前写的Xposed相关文章合并到一块,方便查阅 目录 多进程App的Hook问题XposedHelper中的静态变量demo的AndroidManifest.xml的测试核心代码结论限制handleLoadPackage被单个进程多次执行的问题 多dex Hook问题为应用增加权限利用Xposed删除权限参考 Hook框架集锦…...

android studio内存分析之Memory profiler的使用
目录 Android Studio中内存分析工具Memory profiler的使用1. 打开Memory Profiler2. 工具使用3. 内存选项说明4. 内存性能分析器概览5. 内存计算方式6. 查看内存分配7. 捕获java/kotlin方式查看内存分配8. 堆转储文件导入和导出 内存性能分析器中的泄漏检测 Android Studio中内…...

Qt下载慢/无法下载解决方式
文章目录 一. Qt在线安装下载二. 安装方式 一. Qt在线安装下载 官网下载:https://www.qt.io/download清华源下载:https://mirrors.tuna.tsinghua.edu.cn/qt/official_releases/online_installers/ 二. 安装方式 进入下载好的目录 在目录栏输入CMD&…...

【UE4 RTS】04-Camera Pan
前言 本篇实现了CameraPawn的旋转功能。 效果 步骤 1. 打开项目设置,添加两个操作映射 2. 打开玩家控制器“RTS_PlayerController_BP”,新建一个浮点型变量,命名为“PanSpeed” 在事件图表中添加如下节点 此时运行游戏可以发现当鼠标移动…...

出现raise NotImplementedError报错
在学习《动手学深度学习》时,实现下面代码时,报出raise NotImplementedError错误。 import collections import torch from d2l import torch as d2l import math from torch import nnclass Seq2SeqEncoder(d2l.Encoder):def __init__(self,vocab_size,…...

第一百二十二天学习记录:C++提高:STL-vector容器(上)(黑马教学视频)
vector基本概念 功能: vector数据结构和数组非常相似,也称为单端数组 vector与普通数组区别: 不同之处在于数组是静态空间,而vector可以动态扩展 动态扩展: 并不是在原空间之后续接新的空间,而是找更大的内…...

《Linux从练气到飞升》No.11 初识操作系统
🕺作者: 主页 我的专栏C语言从0到1探秘C数据结构从0到1探秘Linux菜鸟刷题集 😘欢迎关注:👍点赞🙌收藏✍️留言 🏇码字不易,你的👍点赞🙌收藏❤️关注对我真的…...

什么是 XSS 攻击?
概念 XSS 攻击指的是跨站脚本攻击,是一种代码注入攻击。攻击者通过在网站注入恶意脚本,使之在用户的浏览器上运行,从而盗取用户的信息如 cookie 等。 XSS 的本质是因为网站没有对恶意代码进行过滤,与正常的代码混合在一起了&…...

基于Spring Boot的招聘网站的设计与实现(Java+spring boot+MySQL)
获取源码或者论文请私信博主 演示视频: 基于Spring Boot的招聘网站的设计与实现(Javaspring bootMySQL) 使用技术: 前端:html css javascript jQuery ajax thymeleaf 微信小程序 后端:Java springboot框…...

中级课程——CSRF
文章目录 案例原理挖掘 案例 原理 挖掘 挖掘详情 首先就是对目标敏感部位进行抓包分析,比如修改信息、转账、添加信息等等。通常一个数据包HTTP请求头里边都会有一个Referer,这个需要特别去验证。比如放到Burpsuit Repeater里边去测试:去掉…...

面试热题(岛屿数量)
给你一个由 1(陆地)和 0(水)组成的的二维网格,请你计算网格中岛屿的数量。 岛屿总是被水包围,并且每座岛屿只能由水平方向和/或竖直方向上相邻的陆地连接形成。 此外,你可以假设该网格的四条边均…...

【WebRTC---源码篇】(二十四)GCC获取码率后的分配
RtpTransportControllerSend::PostUpdates 配置码率 GoogCcNetworkController::GetPacingRates pacing_factor_默认2.5。也就是说pacer发送报文的码率是探测码率的2.5倍。 PacerConfig GoogCcNetworkController::GetPacingRates(Timestamp at_time) const {// Pacing rate …...

数据可视化工具LightningChart .NET正式发布v10.5.1——拥有全新的3D新功能
LightningChart.NET完全由GPU加速,并且性能经过优化,可用于实时显示海量数据-超过10亿个数据点。 LightningChart包括广泛的2D,高级3D,Polar,Smith,3D饼/甜甜圈,地理地图和GIS图表以及适用于科学…...

AWS认证SAA-C03每日一题
本题库由云计算狂魔微信公众号分享。 【SAA-C03助理级解决方案架构师认证】A company has a multi-tier application that runs six front-end web servers in an Amazon EC2 Auto Scaling group in a single Availability Zone behind an Application Load Balancer(ALB).A …...

ASP.NET Core MVC -- 将视图添加到 ASP.NET Core MVC 应用
Index页 右键单击“视图”文件夹,然后单击“添加”>>“新文件夹”,并将文件夹命名为“HelloWorld”。 右键单击“Views/HelloWorld”文件夹,然后单击“添加”>“新项”。 在“添加新项 - MvcMovie”对话框中: 在右上…...

基于R做宏基因组结果的PCoA分析
写在前面 因为公司给的PCA结果效果不佳,决定从中重新挑选部分样本进行再分析 步骤 表格结果预处理 在属水平genus参考原本结果已有的PCA图,尽可能挑选距离较远且聚团的样本 选取不同样本属水平的丰度数据,整理成逗号分隔的csv文件 代码…...

8.10 算法刷题【1道题】
8.10 算法刷题 22. 链表中环的入口结点(快慢指针) 22. 链表中环的入口结点(快慢指针) 原题链接 /*** Definition for singly-linked list.* struct ListNode {* int val;* ListNode *next;* ListNode(int x) : val(x…...

Apache Maven:从构建到部署,一站式解决方案
目录 一、Maven介绍 1. Maven是什么? 2.Maven的作用? 二、Maven仓库介绍 2.1 库的分类 三、Maven安装与配置 3.1 Maven安装 3.2 Maven环境配置 3.3 仓库配置 四、Eclipse与Maven配置 五、Maven项目测试 5.1 新建Maven项目步骤及注意事项 5.…...

文章四:版本控制策略 - 穿越时光机:Git版本控制进阶技巧
开始本篇文章之前先推荐一个好用的学习工具,AIRIght,借助于AI助手工具,学习事半功倍。欢迎访问:http://airight.fun 概述 版本控制是Git的核心功能,它使得开发者可以记录代码的历史变更,并能够在不同版本…...

爬虫如何应对网站的反爬机制?如何查找user-agent对应的值
import requestsurl https://movie.douban.com/top250 response requests.get(url) # 查看结果 print(response)在requests使用一文中我们有讲到,当状态码不是200时表示爬虫不可用,也就是说我们获取不到网页源代码。但是我们还是可以挣扎一下ÿ…...

一个概率论例题引发的思考
浙江大学版《概率论与梳理统计》一书中的,第13章第1节例2如下: 这个解释和模型比较简单易懂。接下来,第2节的例2是一个关于此模型的题目: 在我自己的理解中,此题的解法跟上一个题目一样,第二级传输后&…...

司徒理财:8.11黄金最新走势分析早盘1914现价多
黄金昨日再次破位新低,但是下跌力度出现衰竭迹象,意味着本次下跌暂时告一段落,行情将会开启一波反弹,早盘1914现价直接多,先看反弹上涨!黄金从走势上看,日线上已经跌至前低附近,也是…...