首页 > 解决方案 > 无法从 powershell 访问 python

问题描述

当我尝试从 Windows 机器上的 powershell 命令提示符访问已安装的 python 时,出现以下错误。

我从从门户下载的 .exe 文件安装了 python,并且在安装时我在启动时检查了环境变量设置选项。

python安装在我的系统上的“C:\Users\username\AppData\Local\Programs\Python\Python38-32”这个位置

任何人都可以帮助我哪里出错了。

错误:当我从系统文件夹中输入 python

PS C:\WINDOWS\system32> python
python : The term 'python' is not recognized as the name of a cmdlet, function, script file, or operable program.
Check the spelling of the name, or if a path was included, verify that the path is correct and try again.
At line:1 char:1
+ python
+ ~~~~~~
    + CategoryInfo          : ObjectNotFound: (python:String) [], CommandNotFoundException
    + FullyQualifiedErrorId : CommandNotFoundException

错误:当我从 python 安装位置键入 python 时

PS C:\Users\username\AppData\Local\Programs\Python\Python38-32> .\python
Python path configuration:
  PYTHONHOME = (not set)
  PYTHONPATH = (not set)
  program name = 'C:\Users\username\AppData\Local\Programs\Python\Python38-32\python.exe'
  isolated = 0
  environment = 1
  user site = 1
  import site = 1
  sys._base_executable = 'C:\\Users\\username\\AppData\\Local\\Programs\\Python\\Python38-32\\python.exe'
  sys.base_prefix = ''
  sys.base_exec_prefix = ''
  sys.executable = 'C:\\Users\\username\\AppData\\Local\\Programs\\Python\\Python38-32\\python.exe'
  sys.prefix = ''
  sys.exec_prefix = ''
  sys.path = [
    'C:\\Users\\username\\AppData\\Local\\Programs\\Python\\Python38-32\\python38.zip',
    '.\\DLLs',
    '.\\lib',
    'C:\\Users\\username\\AppData\\Local\\Programs\\Python\\Python38-32',
  ]
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 0x000034d8 (most recent call first):
<no Python frame>

标签: pythonpython-3.x

解决方案


你在环境变量中设置了吗?

看这里

在您的计算机中设置 python 环境变量


推荐阅读