python 机器移植
利用的是python的pip功能(今天上python官网,发现2.7竟然在上个月更新了个新版本 惊诧!现在安装默认自带PIP)
从老机器执行
pip freeze > requirements.txt
新机器安装python版本后运行
pip install -r requirements.txt
就会一个一个安装的,当然会有一定的坑
坑1:
有些版本被官方删除了,建议本地也更新版本 毕竟删除版本可能有什么严重的BUG
坑2:
有些windows的是用exe安装的。需要去官网重新下载EXE
提示以下报错的解决方案
Python version 2.7 required, which was not found in the registry
建立一个文件 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()
坑3:
error: Microsoft Visual C++ 9.0 is required. Get it from http://aka.ms/vcpython27
去http://aka.ms/vcpython27下相关组件