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

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/4320761/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-08-18 15:15:22  来源:igfitidea点击:

importError: no module named _winreg python3

pythoncx-freezewinreg

提问by BantuCoder

Where can I download _winreg for python3 if I can at all. I have my 'windir' on E:\Windows. I do not know if cx_Freeze did not notice that. I am using cx_Freeze to create an msi installer.

如果可以的话,我在哪里可以下载 python3 的 _winreg。我在 E:\Windows 上有我的“windir”。不知道 cx_Freeze 有没有注意到。我正在使用 cx_Freeze 创建 msi 安装程序。

回答by Velociraptors

As it says in the _winreg documentation, it has been renamed to winregin Python 3.0. You should run the 2to3tool if you're converting code that was written for Python 2.x.

正如_winreg 文档所说,它已winreg在 Python 3.0 中重命名为。如果要转换为 Python 2.x 编写的代码,则应运行2to3工具。

回答by np8

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.

我知道这是一个老问题,但这是谷歌搜索时的第一个搜索结果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. The solution was recreate the virtual environment:

尝试使用使用不同(已删除)python 二进制文件创建的虚拟环境文件夹时,我遇到了同样的错误。解决方案是重新创建虚拟环境:

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

回答by Chikku Jacob

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. Hope it can help many people with the same problem.

我为此找到了一个简单的解决方案,尽管我在大量 Rnd 之后找到了它,但解决方案的实现是如此简单和直接。希望它能帮助很多有同样问题的人。

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 (e.g) 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.

  2. select the pip package you want to import. Recompile the code and the error will clear.

  1. 从设置菜单创建新的虚拟环境并选择最新版本的 python 框架作为项目解释器并给出一个新的文件夹路径。

  2. 选择要导入的 pip 包。重新编译代码,错误就会清除。

Hope this helps.

希望这可以帮助。

回答by user11029045

When you encounter an error like module of simpleainot found, use

当你遇到类似 module of simpleainot found的错误时,使用

pip install simpleai

in the prompt and then execute. It will get installed.

在提示中然后执行。它将被安装。