python pip 安装 mod_wsgi 失败,可能是 Unicode 错误

3 投票
1 回答
2410 浏览
提问于 2025-04-18 08:00

我正在尝试用Flask来搭建一个网页应用。我有一台运行CentOS的VPS,并且安装了Apache 2.2.26。

当我在虚拟环境中或者在我的主Python安装上运行 pip install mod_wsgi 时,出现了以下错误。

第一个错误是在Python的错误信息之前打印出来的...

/usr/bin/ld: /home5/arguably/python27/lib/python2.7/config/libpython2.7.a(abstra     ct.o): relocation R_X86_64_32 against `.rodata.str1.8' can not be used when maki     ng a shared object; recompile with -fPIC

/home5/arguably/python27/lib/python2.7/config/libpython2.7.a: could not read sym     bols: Bad value

collect2: ld returned 1 exit status

error: command 'gcc' failed with exit status 1

这个错误是在查看我的主Python安装,而不是我的虚拟环境所在的位置。

接下来的Python错误信息...

Traceback (most recent call last):
  File "/home/arguably/webapps/ers_2/ers2venv/bin/pip", line 11, in <module>
    sys.exit(main())
  File "/home/arguably/webapps/ers_2/ers2venv/lib/python2.7/site-packages/pip/__     init__.py", line 185, in main
    return command.main(cmd_args)
  File "/home/arguably/webapps/ers_2/ers2venv/lib/python2.7/site-packages/pip/ba     secommand.py", line 161, in main
    text = '\n'.join(complete_log)
UnicodeDecodeError: 'ascii' codec can't decode byte 0xe2 in position 43: ordinal not in range(128)

这个错误确实是在查看我的虚拟环境。

在Python错误信息中的一行是 text = '\n'.join(complete_log) ..

if store_log:
            log_file_fn = options.log_file
            text = '\n'.join(complete_log)
            try:
                log_file_fp = open_logfile(log_file_fn, 'w')
            except IOError:
                temp = tempfile.NamedTemporaryFile(delete=False)
                log_file_fn = temp.name
                log_file_fp = open_logfile(log_file_fn, 'w')

1 个回答

5

你的Python安装没有包含共享库。这是mod_wsgi所需要的。你可以查看mod_wsgi的文档了解更多信息。

建议你重新从头安装Python,这次在构建时要在configure脚本中加上--enable-shared这个选项。

撰写回答