[英]Encountering Fatal Python error when I try to use pip in command prompt
I am a new programmer who is trying to follow this tutorial about pip .我是一名新程序员,正在尝试遵循有关 pip 的教程。
In the tutorial, you are asked to go into command prompt and type 'pip'.在本教程中,您被要求将 go 进入命令提示符并键入“pip”。 You are supposed to get a list of general options and commands.
你应该得到一个通用选项和命令的列表。 However, when I type pip in my command prompt, I get this instead:
但是,当我在命令提示符中键入 pip 时,我得到了这个:
C:\Users\myusername>pip
Python path configuration:
PYTHONHOME = (not set)
PYTHONPATH = (not set)
program name = 'C:\Users\myusername\AppData\Local\Programs\Python\Python310\python.exe'
isolated = 0
environment = 1
user site = 1
import site = 1
sys._base_executable = 'C:\\Users\\myusername\\AppData\\Local\\Programs\\Python\\Python310\\python.exe'
sys.base_prefix = ''
sys.base_exec_prefix = ''
sys.platlibdir = 'lib'
sys.executable = 'C:\\Users\\myusername\\AppData\\Local\\Programs\\Python\\Python310\\python.exe'
sys.prefix = ''
sys.exec_prefix = ''
sys.path = [
'C:\\Users\\myusername\\AppData\\Local\\Programs\\Python\\Python310\\python310.zip',
'.\\DLLs',
'.\\lib',
'C:\\Users\\myusername\\AppData\\Local\\Programs\\Python\\Python310',
]
Fatal Python error: init_fs_encoding: failed to get the Python codec of the filesystem encoding
Python runtime state: core initialized
ModuleNotFoundError: No module named 'encodings'
Current thread 0x00007590 (most recent call first):
<no Python frame>
(I am using Windows 10 and Python 3.10.4) (我正在使用 Windows 10 和 Python 3.10.4)
I do not know what this means.我不知道这是什么意思。 This is not addressed in the video.
视频中没有解决这个问题。 This happens whenever I do anything pip-related in the command prompt.
每当我在命令提示符下执行任何与 pip 相关的操作时,都会发生这种情况。 I am going to reference this error a lot, so let's call it "The Error."
我会经常提到这个错误,所以我们称它为“错误”。
Here is how I have tried to resolve this problem:以下是我尝试解决此问题的方法:
python get-pip.py
.python get-pip.py
通过命令提示符安装它。 This returns The Error.py -3 -m ensurepip
and py -m ensurepip --upgrade
in the command prompt.py -3 -m ensurepip
和py -m ensurepip --upgrade
。 This returns The Error. Click here to see my image点击这里查看我的图片
C:\Users\myusername\AppData\Local\Programs\Python\Python310\Scripts
and trying pip --version
and pip install camelcase
from there.C:\Users\myusername\AppData\Local\Programs\Python\Python310\Scripts
并尝试pip --version
和pip install camelcase
。 This returns The Error.python --version
returns Python 3.10.4
, this works as expected. python --version
返回Python 3.10.4
,这按预期工作。This is not a Python bug, this is a symptom of setting PYTHONHOME and/or PYTHONPATH when they’re not needed. In nearly all cases you don’t need to set either of them;
In the case of PYTHONHOME it’s almost always a mistake to set.
This does not apply to my case, because my PYTHONHOME and PYTHONPATH are not set.这不适用于我的情况,因为我的 PYTHONHOME 和 PYTHONPATH 没有设置。 The commands
unset PYTHONPATH
and unset PYTHONHOME
return 'unset' is not recognized as an internal or external command, operable program or batch file.
命令
unset PYTHONPATH
和unset PYTHONHOME
return 'unset' is not recognized as an internal or external command, operable program or batch file.
I have no idea what's going on and I am confused.我不知道发生了什么,我很困惑。 All I want to do is go into the command prompt, type
pip
and see the list of commands that is supposed to come up.我想做的只是 go 进入命令提示符,输入
pip
并查看应该出现的命令列表。 I also want to be able to install python modules using pip.我还希望能够使用 pip 安装 python 模块。 These seem like basic things that should automatically work, yet for some reason I am encountering a problem that is out of my depth.
这些似乎是应该自动工作的基本事情,但由于某种原因,我遇到了一个超出我深度的问题。
I am not trying to do anything fancy.我不想做任何花哨的事情。 I am a basic user who has been learning basic Python for less than a month, with no prior coding experience.
我是一个基础用户,学习基础Python不到一个月,之前没有任何编码经验。 How can I overcome this error so I can successfully use pip?
如何克服此错误,以便成功使用 pip? Please keep my level of understanding in mind when you answer my question.
当您回答我的问题时,请记住我的理解水平。 Thank you!
谢谢!
The answer was to uninstall and reinstall python, this time telling it to set environment variables.答案是卸载并重新安装 python,这一次告诉它设置环境变量。 That did the trick.
那成功了。
Thanks, I had the same problem and reinstallation of python solved my problem.谢谢,我遇到了同样的问题,重新安装 python 解决了我的问题。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.