《Python系列》Python常见问题处理记录

文章目录
  • Python常见问题处理记录
  • 一、Python使用pip报错和安装pyinstaller报错
    • 1.使用pip报错
    • 2.使用pip安装pyinstaller报错
  • 二、使用Python报错:Fatal Python error: initfsencoding: Unable to get the locale encoding
  • 三、多版本python导致yum使用异常,No module named yum
    • 1 问题详情
    • 2 问题解决
    • 3 处理测试

Python常见问题处理记录

一、Python使用pip报错和安装pyinstaller报错

1.使用pip报错

D:\date\IDEA\Game\PyInstaller-3.4>pip install pyinstaller
'pip' 不是内部或外部命令,也不是可运行的程序
或批处理文件。

解决方案:添加环境变量

新增系统变量:
变量名:PYTHON_HOME
变量值:D:\software\anaconda3\Scripts
修改path变量:
	添加:%PYTHON_HOME%


2.使用pip安装pyinstaller报错

D:\date\IDEA\Game\PyInstaller-3.4>pip install pyinstaller
WARNING: pip is configured with locations that require TLS/SSL, however the ssl module in Python is not available.
Looking in indexes: https://pypi.tuna.tsinghua.edu.cn/simple
WARNING: Retrying (Retry(total=4, connect=None, read=None, redirect=None, status=None)) after connection broken by 'SSLError("Can't connect to HTTPS URL because the SSL module is not available.")': /simple/pyinstaller/
WARNING: Retrying (Retry(total=3, connect=None, read=None, redirect=None, status=None)) after connection broken by 'SSLError("Can't connect to HTTPS URL because the SSL module is not available.")': /simple/pyinstaller/
WARNING: Retrying (Retry(total=2, connect=None, read=None, redirect=None, status=None)) after connection broken by 'SSLError("Can't connect to HTTPS URL because the SSL module is not available.")': /simple/pyinstaller/
WARNING: Retrying (Retry(total=1, connect=None, read=None, redirect=None, status=None)) after connection broken by 'SSLError("Can't connect to HTTPS URL because the SSL module is not available.")': /simple/pyinstaller/
WARNING: Retrying (Retry(total=0, connect=None, read=None, redirect=None, status=None)) after connection broken by 'SSLError("Can't connect to HTTPS URL because the SSL module is not available.")': /simple/pyinstaller/
Could not fetch URL https://pypi.tuna.tsinghua.edu.cn/simple/pyinstaller/: There was a problem confirming the ssl certificate: HTTPSConnectionPool(host='pypi.tuna.tsinghua.edu.cn', port=443): Max retries exceeded with url: /simple/pyinstaller/ (Caused by SSLError("Can't connect to HTTPS URL because the SSL module is not available.")) - skipping
ERROR: Could not find a version that satisfies the requirement pyinstaller (from versions: none)
ERROR: No matching distribution found for pyinstaller
WARNING: pip is configured with locations that require TLS/SSL, however the ssl module in Python is not available.
Could not fetch URL https://pypi.tuna.tsinghua.edu.cn/simple/pip/: There was a problem confirming the ssl certificate: HTTPSConnectionPool(host='pypi.tuna.tsinghua.edu.cn', port=443): Max retries exceeded with url: /simple/pip/ (Caused by SSLError("Can't connect to HTTPS URL because the SSL module is not available.")) - skipping

解决方案:添加信任源

D:\date\IDEA\Game\PyInstaller-3.4>pip install  pyinstaller  --index-url http://pypi.douban.com/simple/    --trusted-host pypi.douban.com
Looking in indexes: http://pypi.douban.com/simple/
Collecting pyinstaller
  Downloading http://pypi.doubanio.com/packages/da/98/ba0071620a2bd672cd98b398653517a296f988a8271d9d2f365a7922a51b/pyinstaller-4.7-py3-none-win_amd64.whl (2.0 MB)
     |████████████████████████████████| 2.0 MB 2.2 MB/s
Requirement already satisfied: pywin32-ctypes>=0.2.0 in d:\software\anaconda3\lib\site-packages (from pyinstaller) (0.2.0)
Collecting pyinstaller-hooks-contrib>=2020.6
  Downloading http://pypi.doubanio.com/packages/80/74/4c885df43604c4ae570610e187052f29d806d582e398c2e48b83dad74610/pyinstaller_hooks_contrib-2021.4-py2.py3-none-any.whl (215 kB)
     |████████████████████████████████| 215 kB ...
Collecting pefile>=2017.8.1
  Downloading http://pypi.doubanio.com/packages/ee/e1/a7bd302cf5f74547431b4e9b206dbef782d112df6b531f193bb4a29fb1b9/pefile-2021.9.3.tar.gz (72 kB)
     |████████████████████████████████| 72 kB ...
Collecting altgraph
  Downloading http://pypi.doubanio.com/packages/84/3f/1a5c9bef54cac9bf41edd6f4aaf61cd52ed578e10ccc607e0278012cb4a5/altgraph-0.17.2-py2.py3-none-any.whl (21 kB)
Requirement already satisfied: setuptools in d:\software\anaconda3\lib\site-packages (from pyinstaller) (58.0.4)
Requirement already satisfied: future in d:\software\anaconda3\lib\site-packages (from pefile>=2017.8.1->pyinstaller) (0.18.2)
Building wheels for collected packages: pefile
  Building wheel for pefile (setup.py) ... done
  Created wheel for pefile: filename=pefile-2021.9.3-py3-none-any.whl size=68844 sha256=139bf21106643db9019b3f0c33e2da41e2bda609170130bb24491cf1a5eeba0a
  Stored in directory: c:\users\edz\appdata\local\pip\cache\wheels\7b\f8\a2\c28c8f2797bf32ae30e18da14e5a5ab9cfbfb72da03593426d
Successfully built pefile
Installing collected packages: pyinstaller-hooks-contrib, pefile, altgraph, pyinstaller
Successfully installed altgraph-0.17.2 pefile-2021.9.3 pyinstaller-4.7 pyinstaller-hooks-contrib-2021.4


二、使用Python报错:Fatal Python error: initfsencoding: Unable to get the locale encoding

[root@zxy bin]# python3
Fatal Python error: initfsencoding: Unable to get the locale encoding
ModuleNotFoundError: No module named 'encodings'

Current thread 0x00007f439bff2740 (most recent call first):
Aborted

[root@zxy bin]# unset PYTHONHOME

[root@zxy bin]# python3
Python 3.7.3 (default, Mar 21 2023, 15:43:47)
[GCC 4.8.5 20150623 (Red Hat 4.8.5-44)] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>>


三、多版本python导致yum使用异常,No module named yum

1 问题详情

[root@zxy Python-3.7.3]# yum -h
There was a problem importing one of the Python modules
required to run yum. The error leading to this problem was:

   No module named yum

Please install a package which provides this module, or
verify that the module is installed correctly.

It's possible that the above module doesn't match the
current version of Python, which is:
2.7.5 (default, Nov 16 2020, 22:23:17)
[GCC 4.8.5 20150623 (Red Hat 4.8.5-44)]

If you cannot solve this problem yourself, please go to
the yum faq at:
  http://yum.baseurl.org/wiki/Faq

2 问题解决

# 查找python变量
[root@zxy Python-3.7.3]# env | grep PYTHON
PYTHONHOME=/usr/bin
PYTHONPATH=/usr/lib64/python2.7
# 删除PYTHONPATH和PYTHONHOME变量
[root@zxy Python-3.7.3]# unset PYTHONPATH
[root@zxy Python-3.7.3]# unset PYTHONHOME
# 检查是否删除成功
[root@zxy Python-3.7.3]# env | grep PYTHON

3 处理测试

[root@zxy Python-3.7.3]# yum -h
Loaded plugins: fastestmirror, langpacks
Usage: yum [options] COMMAND

List of Commands:

check          Check for problems in the rpmdb
check-update   Check for available package updates
clean          Remove cached data
deplist        List a package's dependencies
distribution-synchronization Synchronize installed packages to the latest available versions
downgrade      downgrade a package
erase          Remove a package or packages from your system
fs             Acts on the filesystem data of the host, mainly for removing docs/lanuages for minimal hosts.
fssnapshot     Creates filesystem snapshots, or lists/deletes current snapshots.
groups         Display, or use, the groups information
help           Display a helpful usage message


🤝 期待与你共同进步

🌱 亲爱的读者,非常感谢你每一次的停留和阅读!你的支持是我们前行的最大动力!🙏

🌐 在这茫茫网海中,有你的关注,我们深感荣幸。你的每一次点赞👍、收藏🌟、评论💬和关注💖,都像是明灯一样照亮我们前行的道路,给予我们无比的鼓舞和力量。🌟

📚 我们会继续努力,为你呈现更多精彩和有深度的内容。同时,我们非常欢迎你在评论区留下你的宝贵意见和建议,让我们共同进步,共同成长!💬

💪 无论你在编程的道路上遇到什么困难,都希望你能坚持下去,因为每一次的挫折都是通往成功的必经之路。我们期待与你一起书写编程的精彩篇章! 🎉

🌈 最后,再次感谢你的厚爱与支持!愿你在编程的道路上越走越远,收获满满的成就和喜悦

关于Python学习指南


如果想要系统学习Python、Python问题咨询,或者考虑做一些工作以外的副业,都可以扫描二维码添加微信,围观朋友圈一起交流学习。

我们还为大家准备了Python资料和副业项目合集,感兴趣的小伙伴快来找我领取一起交流学习哦!

学好 Python 不论是就业还是做副业赚钱都不错,但要学会 Python 还是要有一个学习规划。最后给大家分享一份全套的 Python 学习资料,给那些想学习 Python 的小伙伴们一点帮助!

包括:Python激活码+安装包、Python web开发,Python爬虫,Python数据分析,人工智能、自动化办公等学习教程。带你从零基础系统性的学好Python!

👉Python所有方向的学习路线👈

Python所有方向路线就是把Python常用的技术点做整理,形成各个领域的知识点汇总,它的用处就在于,你可以按照上面的知识点去找对应的学习资源,保证自己学得较为全面。(全套教程文末领取)

在这里插入图片描述

👉Python学习视频600合集👈

观看零基础学习视频,看视频学习是最快捷也是最有效果的方式,跟着视频中老师的思路,从基础到深入,还是很容易入门的。

在这里插入图片描述

温馨提示:篇幅有限,已打包文件夹,获取方式在:文末
👉Python70个实战练手案例&源码👈

光学理论是没用的,要学会跟着一起敲,要动手实操,才能将自己的所学运用到实际当中去,这时候可以搞点实战案例来学习。

在这里插入图片描述

👉Python大厂面试资料👈

我们学习Python必然是为了找到高薪的工作,下面这些面试题是来自阿里、腾讯、字节等一线互联网大厂最新的面试资料,并且有阿里大佬给出了权威的解答,刷完这一套面试资料相信大家都能找到满意的工作。

在这里插入图片描述

在这里插入图片描述

👉Python副业兼职路线&方法👈

学好 Python 不论是就业还是做副业赚钱都不错,但要学会兼职接单还是要有一个学习规划。

在这里插入图片描述

👉 这份完整版的Python全套学习资料已经上传,朋友们如果需要可以扫描下方CSDN官方认证二维码或者点击链接免费领取保证100%免费

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值