【发布时间】:2019-10-06 19:54:26
【问题描述】:
在一个相当保守的系统 (RHEL) 上,我决定尝试一下,了解 virtualenv 并将我的 wsgi 应用程序从系统的默认 2.7 迁移到 3.6。有很多 Python3 版本可供选择:
$ yum search python3 | egrep '^python3[^-]+\.'
python34.x86_64 : Version 3 of the Python programming language aka Python 3000
python34u.x86_64 : Version 3 of the Python programming language aka Python 3000
python35u.x86_64 : Version 3.5 of the Python programming language
python36.x86_64 : Interpreter of the Python programming language
python36u.x86_64 : Interpreter of the Python programming language
$
我最终在 virtualenv 中安装了 python36。一切都在测试设置中正常工作,所以现在是时候安装正确的 apache 模块了。但是,virtualenv 和 mod_wsgi 似乎是互斥的,因为它们在 python3 中没有共同的版本:
$ yum search python | egrep '(virtualenv|mod_wsgi)'
python-virtualenv.noarch : Tool to create isolated Python environments
python3-virtualenv-doc.noarch : Documentation for python virtualenv
python34-virtualenv.noarch : Documentation for python virtualenv
python35u-mod_wsgi.x86_64 : A WSGI interface for Python web applications in
python35u-mod_wsgi-debuginfo.x86_64 : Debug information for package
: python35u-mod_wsgi
python36-virtualenv.noarch : Documentation for python virtualenv
python36u-mod_wsgi.x86_64 : A WSGI interface for Python web applications in
python36u-mod_wsgi-debuginfo.x86_64 : Debug information for package
: python36u-mod_wsgi
mod_wsgi.x86_64 : A WSGI interface for Python web applications in Apache
python-virtualenv-api.noarch : An API for virtualenv/pip
python-virtualenv-clone.noarch : Script to clone virtualenvs
python-virtualenvwrapper.noarch : Enhancements to virtualenv
$
请注意,mod_wsgi 软件包有“35u”和“36u”版本号,而 virtualenv 只有“34”和“36”。当我尝试同时安装任何一个时,我会收到大量的冲突错误消息。
当然python27(默认系统版本)还在,所以我尝试使用27的virtualenv创建一个python36环境,但也失败了:
$ virtualenv -p python3.6 env
Running virtualenv with interpreter /usr/bin/python3.6
Traceback (most recent call last):
File "/usr/lib/python2.7/site-packages/virtualenv.py", line 8, in <module>
import base64
File "/usr/lib64/python3.6/base64.py", line 9, in <module>
import re
File "/usr/lib64/python3.6/re.py", line 142, in <module>
class RegexFlag(enum.IntFlag):
AttributeError: module 'enum' has no attribute 'IntFlag'
$
RHEL 是我必须忍受的,因为这是在我公司的 Intranet 中的某些 VM 上运行的。我在家里运行 Debian,没有问题。我也不能使用不同的网络服务器,因为其他人在该服务器上有不同的应用程序(PHP)。
【问题讨论】:
标签: python-3.x virtualenv rhel selinux