简体   繁体   English

导入错误:没有名为 _winreg python3 的模块

[英]importError: no module named _winreg python3

Where can I download _winreg for python3 if I can at all.如果可以的话,我在哪里可以下载 python3 的 _winreg。 I have my 'windir' on E:\\Windows.我在 E:\\Windows 上有我的“windir”。 I do not know if cx_Freeze did not notice that.不知道 cx_Freeze 有没有注意到。 I am using cx_Freeze to create an msi installer.我正在使用 cx_Freeze 创建 msi 安装程序。

As it says in the _winreg documentation , it has been renamed to winreg in Python 3.0.正如_winreg 文档所说,它已在 Python 3.0 中重命名为winreg You should run the 2to3 tool if you're converting code that was written for Python 2.x.如果要转换为 Python 2.x 编写的代码,则应运行2to3工具。

I know this is an old question, but this was the first search result when Googling for ModuleNotFoundError: No module named '_winreg' , and perhaps may be helpful for someone.我知道这是一个老问题,但这是 Google 搜索ModuleNotFoundError: No module named '_winreg'时的第一个搜索结果,也许对某人有帮助。

I got the same error when trying to use a virtual environment folder, which has been created using different (already deleted) python binaries.尝试使用使用不同(已删除)python 二进制文件创建的虚拟环境文件夹时,我遇到了同样的错误。 The solution was recreate the virtual environment:解决方案是重新创建虚拟环境:

  1. Delete the virtual environment folder删除虚拟环境文件夹
  2. Run python -m venv <name_of_virtual_environment>运行python -m venv <name_of_virtual_environment>

I have found an easy solution for this, Even though i found it after a lot of Rnd, the solution implementation is so simple and straight forward.我为此找到了一个简单的解决方案,尽管我在大量 Rnd 之后找到了它,但解决方案的实现是如此简单和直接。 Hope it can help many people with the same problem.希望它能帮助很多有同样问题的人。

If you dont have the latest version of Python installed on your machine, You need to download it from ( https://www.python.org/downloads/ ) and then click on Add to path option and just finish the installer.如果您的机器上没有安装最新版本的 Python,您需要从 ( https://www.python.org/downloads/ ) 下载它,然后单击添加到路径选项并完成安装程序。

Please open CMD and move to the python latest version directory, then run the pip install package name (eg) pip install pygame and it will be successful请打开CMD并移动到python最新版本目录,然后运行pip install包名(如)pip install pygame即可成功

1. C:\WINDOWS\system32>cd C:\Users\admin\AppData\Local\Programs\Python\Python37-32

    2. C:\Users\admin\AppData\Local\Programs\Python\Python37-32>pip install Pygame 

It will install the packages now without any issues.它将立即安装软件包,没有任何问题。

Downloading Successfully installed Pygame-1.9.4下载成功安装Pygame-1.9.4

C:\\Users\\admin\\AppData\\Local\\Programs\\Python\\Python37-32> C:\\Users\\admin\\AppData\\Local\\Programs\\Python\\Python37-32>

If you are still facing issues in Pycharm after trying the above solution, please try the following steps too.如果您在尝试上述解决方案后仍然在 Pycharm 中遇到问题,也请尝试以下步骤。

  1. Create new virtual Environment from settings menu and select the latest version of python framework as Project Interpreter and give a new folder path.从设置菜单创建新的虚拟环境并选择最新版本的 python 框架作为项目解释器并给出一个新的文件夹路径。

  2. select the pip package you want to import.选择要导入的 pip 包。 Recompile the code and the error will clear.重新编译代码,错误就会清除。

Hope this helps.希望这可以帮助。

When you encounter an error like module of simpleai not found, use当遇到类似module of simpleai not found之类的错误时,使用

pip install simpleai

in the prompt and then execute.在提示中然后执行。 It will get installed.它将被安装。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM