返回
基础
分类

新建一个register.py 文件,把安装路径和脚本路径添加到path中

日期: 2020-01-02 08:07 浏览次数 : 171

新建一个register.py 文件,把安装路径和脚本路径添加到path中。python version 2. required,which was not found in the registry 解决方案,pythonrequired

不能在注册表中识别python2.7

新建一个register.py 文件

import sys

from _winreg import *

# tweak as necessary
version = sys.version[:3]
installpath = sys.prefix

regpath = "SOFTWARE\Python\Pythoncore\%s\" % (version)
installkey = "InstallPath"
pythonkey = "PythonPath"
pythonpath = "%s;%s\Lib\;%s\DLLs\" % (
    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()

用Python 运行register.py后就能识别python2.7了

version 2. required,which was not found in the registry 解决方案,pythonrequired 不能在注册表中识别python2.7 新建一个register.py 文件 import sys from _wi...

Python version 2.7 required, which was not found in the registry,pythonrequired

安装PIL库的时候,直接提示:Python version 2.7 required, which was not found in the registry。
如图:

必赢手机登录网址 1

大意是说找不到注册表,网上搜索解决方案。

新建一个register.py文件写入代码:

复制代码 代码如下:

import sys
  
from _winreg import *
  
# tweak as necessary
version = sys.version[:3]
installpath = sys.prefix
  
regpath = "SOFTWARE\Python\Pythoncore\%s\" % (version)
installkey = "InstallPath"
pythonkey = "PythonPath"
pythonpath = "%s;%s\Lib\;%s\DLLs\必赢手机登录网址 ," % (
    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!"

启动命令切到register.py文件目录下执行:

必赢手机登录网址 2

重新安装PIL,错误解决,安装成功。

如果是win7 64位的用户在安装Python 32位程序时,如果选择只为当前用户,以上问题不会出现。如果选择所有用户,就试着使用以上方法解决。

提示其它版本解决方法类似。

在win10的环境下安装scrapy,并不能直接按照官网的手册()一次性安装成功,根据我自己的安装过程中遇到的问题,特意整理了一下安装过程

软件安装出现python version 27 required,which was not found in the registry 怎解决?附图

你要先自己下载安装python2.7,  

1.下载安装python2.7.11

python安装一个工具 错误 no python installation found in the registry

重新安装下python 在安装呗
看这个错误提示好像是没有找到python  

version 2.7 required, which was not found in the registry,pythonrequired 安装PIL库的时候,直接提示:Python version 2.7 required, which was not found in the reg...

 

2.安装完成之后,把安装路径和脚本路径添加到path中,譬如:C:Python27;C:Python27Scripts;

 

3.安装pywin32,在下面的连接中下载最新版的pywin32

我在安装pywin32过程中遇到错误提示:

python version 2.7 required,which was not found in the registry

这是因为注册表不能识别出python2.7,解决方法就是新建一个register.py文件,运行下面的代码

#
# script to register Python 2.0 or later for use with win32all
# and other extensions that require Python registry settings
#
# written by Joakim Loew for Secret Labs AB / PythonWare
#
# source:
# http://www.pythonware.com/products/works/articles/regpy20.htm
#
# modified by Valentine Gogichashvili as described in http://www.mail-archive.com/distutils-sig@python.org/msg10512.html

import sys

from _winreg import *

# tweak as necessary
version = sys.version[:3]
installpath = sys.prefix

regpath = "SOFTWARE\Python\Pythoncore\%s\" % (version)
installkey = "InstallPath"
pythonkey = "PythonPath"
pythonpath = "%s;%s\Lib\;%s\DLLs\" % (
    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()

运行成功后显示:python 2.7 is already registered,然后再次安装pywin32

 

4.接着安装lxml,并不能直接使用命令pip install lxml来安装,此时就使用第三方的安装方法,到这里(

lxml-3.5.0-cp27-none-win32.whl

然后在存放该下载文件的目录下执行命令:pip install lxml-3.5.0-cp27-none-win32.whl

 

5.运行命令:pip install scrapy来安装scrapy,如果遇到如下错误提示:

Microsoft Visual C++ 9.0 is required Unable to find vcvarsall.bat

则到这里: 下载并安装vc++插件