在这篇文章【[Python模块]Windows环境安装PyV8并执行js语句:https://blog.csdn.net/sc_lilei/article/details/79946029】的基础上填坑补充:
在window下安装那个【python2的pyv8:https://pan.baidu.com/s/1rKPqPVidhHzwLT9eYiqFOw】时出现【 Python version 2.7 required, which was not found in the registry】,参考【https://blog.csdn.net/zklth/article/details/8117207】,就是用你的python2执行以下脚本,然后再去点击安装那个pyv8的exe文件。
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 | 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脚本又发现一个问题【ImportError: DLL load failed: 找不到指定的模块。】,参考【win10环境下python3如何使用PyV8:https://www.pythonheidong.com/blog/article/324801/】&【https://github.com/emmetio/pyv8-binaries】这篇文章中提到的python2中只有python2.6才适用,果断切换到python2.6,不过还是失败了,算了,暂时搁置了。