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

清疚 2021-06-24 14:36 440阅读 0赞

安装gensim-0.13.3.win-amd64-py2.7的时候,提示:Python version 2.7 required, which was not found in the registry

解决方法如下,将下面文件保存到regist.py,然后执行python regist.py

  1. #
  2. # script to register Python 2.0 or later for use with win32all
  3. # and other extensions that require Python registry settings
  4. #
  5. # written by Joakim Loew for Secret Labs AB / PythonWare
  6. #
  7. # source:
  8. # http://www.pythonware.com/products/works/articles/regpy20.htm
  9. #
  10. # modified by Valentine Gogichashvili as described in http://www.mail-archive.com/distutils-sig@python.org/msg10512.html
  11. import sys
  12. from _winreg import *
  13. # tweak as necessary
  14. version = sys.version[:3]
  15. installpath = sys.prefix
  16. regpath = "SOFTWARE\\Python\\Pythoncore\\%s\\" % (version)
  17. installkey = "InstallPath"
  18. pythonkey = "PythonPath"
  19. pythonpath = "%s;%s\\Lib\\;%s\\DLLs\\" % (
  20. installpath, installpath, installpath
  21. )
  22. def RegisterPy():
  23. try:
  24. reg = OpenKey(HKEY_CURRENT_USER, regpath)
  25. except EnvironmentError as e:
  26. try:
  27. reg = CreateKey(HKEY_CURRENT_USER, regpath)
  28. SetValue(reg, installkey, REG_SZ, installpath)
  29. SetValue(reg, pythonkey, REG_SZ, pythonpath)
  30. CloseKey(reg)
  31. except:
  32. print "*** Unable to register!"
  33. return
  34. print "--- Python", version, "is now registered!"
  35. return
  36. if (QueryValue(reg, installkey) == installpath and
  37. QueryValue(reg, pythonkey) == pythonpath):
  38. CloseKey(reg)
  39. print "=== Python", version, "is already registered!"
  40. return
  41. CloseKey(reg)
  42. print "*** Unable to register!"
  43. print "*** You probably have another Python installation!"
  44. if __name__ == "__main__":
  45. RegisterPy()

显示“python 2.7 is already registered”

再安装setuptools的时候,就能自动识别出来python2.7了。

win7是 64的原因,在安装python(32位)时,如果选择只为当前用户,以上问题是不会出现的,如果选择所有用户,那就用上面的方法解决吧。

发表评论

表情:
评论列表 (有 0 条评论,440人围观)

还没有评论,来说两句吧...

相关阅读