Chapter 0:Python及nltk准备工作—0.2 Python version -32 required, which was not found in the registry

1 新建register.py文件 (一个新脚本)

2 内容如下

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()

3 文件放入python/scripts文件夹 (前提是设置好系统path)

4 cmd 直接register.py即可

关于 python XX required,。。。 register not found 的解决 - linqingchen6 - 学习点滴

tips:在系统path已设置的前提下 运行pip也好 运行其他脚本也好

既不要胡乱python 也别乱进路径

因为此时cmd一运行 设置的运行路径就是默认的系统path

此次注册问题很可能是因为多次安装不同版本python造成

不但nltk会安装出错,其他一切以python已安装为前提的软件安装都会出错

凌晨大战注册表

以为解决了问题

结果安装nltk还是Python version -32 required, which was not found in the registry 

网上查找解决方法 看来问题还是出在注册表上

然而神奇的是 别人一般都是local machine有注册表 current user没有 我却是反着来的

1 运行-regedit

2 HKEY_CURRENT_USER\software\python\PyhtonCore下的python文件导出 不妨设为3_6.reg

3 编辑3_6.reg,将HKEY_CURRENT_USER全部替换为HKEY_LOCAL_MACHINE(使用文本文件自带编辑-替换功能),保存

4 .双击运行3_6.reg文件,现在HKEY_CURRENT_USER\software\python\PyhtonCore存在了3.6目录了。

python3.6.5安装nltk最终战

1 更新pip 命令行:python -m pip install --upgrade pip

注意upgrade前双-

 python3.6.5安装nltk最终战 - linqingchen6 - 学习点滴


2  直接 pip install nltk 使用命令行从服务器下载安装 

图可见连接很不稳定

python3.6.5安装nltk最终战 - linqingchen6 - 学习点滴

3 第N次重连的时候一个不留神就成功了 随后测试nltk已经可用

python3.6.5安装nltk最终战 - linqingchen6 - 学习点滴

猜你喜欢

转载自blog.csdn.net/DrChenQ/article/details/81195440