【昊鼎王五】pip安装pymssql模块时报错“PEP 517”怎么解决?

本文详细解析了在使用pip安装pymssql模块时遇到的PEP517错误,并提供了解决方案,即通过指定版本限制来安装低于3.0版本的pymssql。

【昊鼎王五】pip安装pymssql模块时报错“PEP 517”怎么解决?

背景

https://blog.youkuaiyun.com/haoding205/article/details/103242102中已经讲到了如何安装pip工具,此篇就讲一个典型的安装第三方库时报错的解决方法。

报错信息

如下图:
在这里插入图片描述

[root@centos tmp]# pip3 install pymssql
Collecting pymssql
  Using cached https://files.pythonhosted.org/packages/4a/20/bcd4db9e7990b50e85280f0c9488c0a53f7e6bf9048203448d8e0f29a536/pymssql-3.0.3.tar.gz
  Installing build dependencies ... done
  Getting requirements to build wheel ... done
  Installing backend dependencies ... done
    Preparing wheel metadata ... done
Building wheels for collected packages: pymssql
  Building wheel for pymssql (PEP 517) ... error
  ERROR: Command errored out with exit status 1:
   command: /usr/local/python3/bin/python3.7 /usr/local/python3/lib/python3.7/site-packages/pip/_vendor/pep517/_in_process.py build_wheel /tmp/tmplktlmv2p
       cwd: /tmp/pip-install-6x1763de/pymssql
  Complete output (42 lines):
  running bdist_wheel
  running build
  installing to build/bdist.linux-x86_64/wheel
  running install
  /tmp/pip-build-env-b2tk6mrs/overlay/lib/python3.7/site-packages/setuptools/dist.py:46: DistDeprecationWarning: Do not call this function
    warnings.warn("Do not call this function", DistDeprecationWarning)
    ...(此处略去1000+字)
File "/usr/local/python3/lib/python3.7/distutils/cmd.py", line 313, in run_command
      self.distribution.run_command(command)
    File "/usr/local/python3/lib/python3.7/distutils/dist.py", line 985, in run_command
      cmd_obj.run()
    File "setup.py", line 449, in run
      raise DeprecationWarning(msg)
  DeprecationWarning: The pymssql project has been discontinued.  To install the last working released version, use a
  version specifier like "pymssql<3.0".  For details and alternatives see:
  https://github.com/pymssql/pymssql/issues/668
  ----------------------------------------
  ERROR: Failed building wheel for pymssql
  Running setup.py clean for pymssql
Failed to build pymssql
ERROR: Could not build wheels for pymssql which use PEP 517 and cannot be installed directly
[root@centos tmp]    

分析

遇到问题不要怕,也不要慌,沉着冷静,总有解决方法。
仔细看报错信息,突然有一条实际上已经告诉了答案。就是版本不匹配,
,那如何才能版本匹配呢?
需要低于3.0版本的pymssql才能安装。

解决命令

命令如下:

pip install "pymssql<3.0"
pip list

如下图:
在这里插入图片描述

总结

当报错信息是版本不匹配时,按照提示信息,输入正确的版本限制语法,安装就成功了。

好了,聪明如你,就讲到这里吧,有问题的话可以留言。
在这里插入图片描述

### 题目重述 用户尝试使用 `pdfplumber` 读取位于桌面的 PDF 文件,但程序报错 `FileNotFoundError`,询问“错在哪里”。目标是定位并解释该错误的根本原因。 --- ### 详解 错误本质是:**Python 找不到指定路径的文件**。尽管代码结构正确,但路径设置有误。 常见错误原因如下: 1. **用户名未正确替换** 使用了示例中的 `YourName` 而不是实际的系统用户名。 ❌ 错误示例: ```python r"C:\Users\YourName\Desktop\example.pdf" ``` ✅ 正确应为(假设真实用户名是“王五”): ```python r"C:\Users\王五\Desktop\example.pdf" ``` 2. **文件名拼写错误或扩展名缺失** - 写成了 `.PDF` 而实际是 `.pdf` - 忽略了文件后缀 `.pdf` - 文件名为 `报告2024.pdf`,但代码中写成 `report.pdf` 3. **路径格式问题(反斜杠被转义)** 没加 `r` 前缀会导致 `\n`, `\t` 等被当作换行或制表符处理。 ❌ 错误: ```python "C:\Users\王五\Desktop\file.pdf" # \t 可能被识别为制表符 ``` ✅ 正确: ```python r"C:\Users\王五\Desktop\file.pdf" ``` 4. **文件其实不在桌面** 有你以为文件在桌面,但实际上保存在“下载”或某个子文件夹中。 5. **路径中含有特殊字符或空格过多** 如 `Desktop\新文档 (副本)\file.pdf`,建议避免复杂路径,可临复制到简单路径测试。 --- ### 知识点(列出解答该问题需要的知识点) - **文件路径解析**:理解绝对路径与相对路径的区别,确保指向真实存在的文件。 - **原始字符串 r"" 的作用**:防止反斜杠被解释为转义字符,保障路径正确性。 - **系统用户名概念**:`C:\Users\XXX` 中的 `XXX` 是登录系统的账户名,需准确填写。
评论 8
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符
 
红包 添加红包
表情包 插入表情
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值