使用本地Python构建安装Python模块
我在本地安装了Python 2.7,路径是~/Python2.7/,现在我需要用到psycopg2这个模块。但是当我尝试用easy_install来安装它,或者手动编译时,出现了错误:
error: invalid Python installation: unable to open /usr/local/lib/python2.7/config/Makefile (No such file or directory)
我试着在~/Python2.7/Lib/sysconfig.py这个文件里改了一行,从
return os.path.join(get_path('stdlib'), "config", "Makefile")
改成
return '/home/foo/Python2.7/Makefile'
但是没有任何效果。我该怎么做才能解决这个问题呢?
1 个回答
2
查看一下命令行选项:http://packages.python.org/distribute/easy_install.html#command-line-options,然后试着调整一下你的 --install-dir 这个参数。如果你想在本地安装,记得把本地安装的路径加到 PYTHONPATH 环境变量里。如果你想把所有东西都安装在本地,建议用 pip 来代替 easy_install,并且设置一个虚拟环境(可以用 virtualenv)。