【发布时间】:2016-09-17 14:55:32
【问题描述】:
我有一个安装了 Red Hat Linux 7.2 的 Amazon EC2 实例。它在系统范围内安装了 Python 2.7.5。
我已经编译了 Python 2.7.8 的替代安装(这是我在尝试复制的另一个环境中使用的)。我将使用它来创建一个 virtualenv 来启动我的 Django 应用程序。
但调用 python2.7 总是将我带到系统范围的 python 2.7.5 解释器。
我按照以下说明操作:http://toomuchdata.com/2014/02/16/how-to-install-python-on-centos/
$ sudo yum groupinstall 'development tools'
$ sudo yum install zlib-dev openssl-devel sqlite-devel bzip2-devel
$ sudo yum install wget
$ sudo wget http://www.python.org/ftp/python/2.7.8/Python-2.7.8.tar.xz
$ sudo yum install xz-libs
$ xz -d Python-2.7.8.tar.xz
$ tar -xvf Python-2.7.8.tar
$ cd Python-2.7.8
编辑文件 /etc/ld.so.conf 以添加该行
/usr/local/lib
$sudo /sbin/ldconfig --> make the dynamic linker aware of the change
$sudo ./configure --prefix=/usr/local --enable-unicode=ucs4 --enable-shared
$make
我收到以下消息,但我不确定这是否与我的问题有关。
Python build finished, but the necessary bits to build these modules were not found:
_bsddb _tkinter bsddb185
dbm dl gdbm
imageop sunaudiodev
To find the necessary bits, look in setup.py in detect_modules() for the module's name.
$sudo make altinstall
$which python
/usr/bin/python ---> system wide Python 2.7.5
$which python2.7
/usr/local/bin/python2.7 ---> this should point to Python 2.7.8 that was compiled and installed.
但调用 python2.7 指向系统范围的 Python 2.7.5 解释器:
$python2.7
Python 2.7.5 (default, Oct 11 2015, 17:47:16)
[GCC 4.8.3 20140911 (Red Hat 4.8.3-9)] on linux2
为什么会这样?
仅供参考,我的 PATH 确实包含 /usr/local/bin。
$echo $PATH
/usr/local/bin:/usr/bin:/usr/local/sbin:/usr/sbin:/home/ec2-user/.local/bin:/home/ec2-user/bin
【问题讨论】:
标签: python linux python-2.7