Ubuntu中psycopg使用错误的Python
我在用Ubuntu系统。我安装了python2.7和最新版本的Postgresql。
当我安装psycopg时,这个软件包出现在Ubuntu默认的python版本里,而不是我想用的2.7版本。
我试着在我想要的目录里重新安装,但它还是指向了另一个python版本。当我打开python命令行时,显示的是2.7版本。
我该怎么把psycopg安装到2.7版本里呢?
谢谢你的帮助。
乔
Stack after installation:
Traceback (most recent call last):
File "/usr/lib/python2.7/site.py", line 562, in <module>
main()
File "/usr/lib/python2.7/site.py", line 544, in main
known_paths = addusersitepackages(known_paths)
File "/usr/lib/python2.7/site.py", line 271, in addusersitepackages
user_site = getusersitepackages()
File "/usr/lib/python2.7/site.py", line 246, in getusersitepackages
user_base = getuserbase() # this will also set USER_BASE
File "/usr/lib/python2.7/site.py", line 236, in getuserbase
USER_BASE = get_config_var('userbase')
File "/usr/lib/python2.7/sysconfig.py", line 543, in get_config_var
return get_config_vars().get(name)
File "/usr/lib/python2.7/sysconfig.py", line 442, in get_config_vars
_init_posix(_CONFIG_VARS)
File "/usr/lib/python2.7/sysconfig.py", line 303, in _init_posix
makefile = _get_makefile_filename()
File "/usr/lib/python2.7/sysconfig.py", line 297, in _get_makefile_filename
return os.path.join(get_path('platstdlib').replace("/usr/local","/usr",1), "config" + (sys.pydebug and "_d" or ""), "Makefile")
AttributeError: 'module' object has no attribute 'pydebug'
2 个回答
Jabs,你需要自己熟悉如何安装和配置项目。之后,手动安装和使用apt-get的区别应该就很明显了。通常来说,使用包管理器和从源代码安装结合起来会很有用,特别是当你想在某些方面保持最新,但在其他方面又不需要时(这样也能节省很多时间)。我建议大部分情况下还是尽量使用包管理器。我注意到你有个评论提到你覆盖了操作系统自带的Python,这通常不是个好主意。
./configure --prefix=
想了解更多,可以使用:
./configure -h
其他环境变量(来自configure -h)
CC C compiler command
CFLAGS C compiler flags
LDFLAGS linker flags, e.g. -L<lib dir> if you have libraries in a
nonstandard directory <lib dir>
LIBS libraries to pass to the linker, e.g. -l<library>
CPPFLAGS (Objective) C/C++ preprocessor flags, e.g. -I<include dir> if
you have headers in a nonstandard directory <include dir>
CPP C preprocessor
在配置和安装Python时,你也可以看看setup.py。
以下这些也有助于搞清楚发生了什么并修复问题:
“在用户路径中找到程序文件” - 我在用哪个可执行文件?
which python
“whereis工具检查标准的二进制目录,查找指定的程序,并打印出找到的路径。”这可能会快速显示我其他的安装。
whereis python
http://kb.iu.edu/data/acar.html
echo $PATH
export PATH=/foo:$PATH
http://docs.python.org/using/cmdline.html#environment-variables
echo $PYTHONPATH
如果使用cmake,这些也可能有用。http://cmake.org/Wiki/CMake_Useful_Variables#Environment_Variables
$CMAKE_FRAMEWORK_PATH $CMAKE_INCLUDE_PATH $CMAKE_LIBRARY_PATH
apt
是用来管理系统软件的,它会使用最开始安装的 Python。
如果你想给自己安装的 Python 添加更多的库,你需要用 easy_install(或者更好用的 pip)来安装这些额外的库。