Python version 3.6 required, which was not found in the registry

本文介绍了解决在Windows环境下安装numpy时遇到的Python 3.3版本未在注册表中找到的问题。提供了注册Python 3.3到Windows注册表的具体Python脚本。

Python version 3.3 required, which was not found in the registry

python registry函数语法

在windows下安装numpy的时候, 出现了"Python version 3.3 required, which was not found in the registry"的错误.

类似的有:Python version 2.7 required, which was not found in the registry

大致意思是说:注册表没有对应的信息. 只要执行一个python脚本,将HKEY_CURRENT_USER (HKCU)注册就好.

2.7版本的可以参照: http://blog.youkuaiyun.com/zklth/article/details/8117207

3.3版本的可以参照: https://gist.github.com/embray/6042780#file-win_register_python-py

相关的说明:

http://pythonhosted.org/pyfits/appendix/faq.html#on-windows-vista-or-later-why-can-t-the-installer-find-python-in-the-registry

其中python3版本的可以执行以下脚本:


from __future__ import print_function
 
 
import sys
 
try:
    from winreg import *
except ImportError:
    from _winreg import *
 
# tweak as necessary
version = sys.version[:3]
installpath = sys.prefix
 
regpath = "SOFTWARE\\Python\\Pythoncore\\{0}\\".format(version)
installkey = "InstallPath"
pythonkey = "PythonPath"
pythonpath = "{0};{1}\\Lib\\;{2}\\DLLs\\".format(
    installpath, installpath, installpath)
 
 
def RegisterPy():
    try:
        reg = OpenKey(HKEY_CURRENT_USER, regpath)
    except EnvironmentError as e:
        try:
            reg = CreateKey(HKEY_CURRENT_USER, regpath)
            SetValue(reg, installkey, REG_SZ, installpath)
            SetValue(reg, pythonkey, REG_SZ, pythonpath)
            CloseKey(reg)
        except:
            print("*** Unable to register!")
            return
        print("--- Python", version, "is now registered!")
        return
    if (QueryValue(reg, installkey) == installpath and
        QueryValue(reg, pythonkey) == pythonpath):
        CloseKey(reg)
        print("=== Python", version, "is already registered!")
        return
    CloseKey(reg)
    print("*** Unable to register!")
    print("*** You probably have another Python installation!")
 
if __name__ == "__main__":
    RegisterPy()



欢迎转载,转载请注明来自一手册:http://yishouce.com/article/62.html

在使用 `LightThreeStreamUncertainty` 模型时,若遇到 `KeyError: 'LightThreeStreamUncertainty is not in the models registry'` 错误,通常意味着该模型未被正确注册到框架的模块系统中。以下是可能的解决方法和排查方向: ### 1. 检查模型是否使用 `register_module()` 注册 在 MMDetection3D 或其他基于 MMCV 的框架中,所有自定义模型都需要使用 `@register_module()` 装饰器进行注册。请确认 `LightThreeStreamUncertainty` 类定义中是否包含如下注册语句: ```python from mmdet3d.models.builder import MODEL @MODEL.register_module() class LightThreeStreamUncertainty(nn.Module): ... ``` 若未注册,请添加上述装饰器,并重新编译或运行代码[^1]。 ### 2. 检查 `__init__.py` 中的 `__all__` 列表 确保模型所在的模块文件夹中的 `__init__.py` 文件中包含了该模型类名在 `__all__` 列表中。例如: ```python __all__ = ['LightThreeStreamUncertainty'] ``` 这一步是为了确保模块在导入时能正确识别该类。 ### 3. 确保模块路径被正确引用 如果模型定义在插件(plugin)目录中,需确保插件路径在配置文件中正确指定,并在运行时被导入。例如,在配置文件中加入: ```python plugin_dir = 'path/to/your/plugin' plugin = True ``` 并在运行脚本前添加路径到 `PYTHONPATH`: ```bash export PYTHONPATH="${PYTHONPATH}:path/to/your/plugin" ``` 此外,可在配置文件解析后动态导入模块,参考如下代码: ```python if hasattr(cfg, 'plugin') and cfg.plugin: import importlib plugin_dir = cfg.plugin_dir _module_dir = os.path.dirname(plugin_dir) _module_path = '.'.join(_module_dir.split('/')) plg_lib = importlib.import_module(_module_path) ``` 此方法可确保插件模块被正确加载[^2]。 ### 4. 检查构建类型(Build Type)是否匹配 MMDet3D 的模块构建类型(如 `MODEL`, `NECK`, `SEGMENTOR` 等)与其他子项目(如 MMDetection 和 MMSegmentation)并不完全兼容。若 `LightThreeStreamUncertainty` 是在 `mmseg` 中注册的,请尝试将其注册方式改为使用 `mmdet3d` 的构建类型,例如: ```python from mmdet3d.models.builder import MODEL @MODEL.register_module() class LightThreeStreamUncertainty: ... ``` 而不是: ```python from mmseg.models.builder import SEGMENTOR ``` 这种不兼容性可能导致模块无法被正确识别[^1]。 ### 5. 重新安装依赖与模块 如果上述方法无效,尝试重新安装项目依赖和模块,确保所有组件版本一致且注册路径正确。执行以下命令: ```bash pip install -r requirements.txt pip install -v -e . ``` 该操作将重新安装所有依赖并编译自定义模块,有助于解决模块未注册或路径错误的问题[^3]。 ---
评论 2
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符
 
红包 添加红包
表情包 插入表情
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值