注:本文中运行的uwsgi是使用miniconda管理的虚拟环境中安装运行的,但是问题的原理是通用的,读者可根据自己的情况自行解决。
问题
# ldd /miniconda3/envs/djangotest/bin/uwsgi
linux-vdso.so.1 => (0x00007ffe1bddf000)
libpthread.so.0 => /lib64/libpthread.so.0 (0x00007f28cf7a2000)
libm.so.6 => /lib64/libm.so.6 (0x00007f28cf51e000)
libdl.so.2 => /lib64/libdl.so.2 (0x00007f28cf31a000)
libz.so.1 => /miniconda3/envs/djangotest/bin/../lib/libz.so.1 (0x00007f28d006d000)
libpcre.so.1 => /miniconda3/envs/djangotest/bin/../lib/libpcre.so.1 (0x00007f28d0024000)
libyaml-0.so.2 => /miniconda3/envs/djangotest/bin/../lib/libyaml-0.so.2 (0x00007f28d0006000)
libjansson.so.4 => /miniconda3/envs/djangotest/bin/../lib/libjansson.so.4 (0x00007f28cfff5000)
libssl.so.1.0.0 => /miniconda3/envs/djangotest/bin/../lib/libssl.so.1.0.0 (0x00007f28cff7b000)
libcrypto.so.1.0.0 => /miniconda3/envs/djangotest/bin/../lib/libcrypto.so.1.0.0 (0x00007f28cf0d1000)
libxml2.so.2 => /miniconda3/envs/djangotest/bin/../lib/libxml2.so.2 (0x00007f28cef69000)
liblzma.so.5 => /miniconda3/envs/djangotest/bin/../lib/liblzma.so.5 (0x00007f28ced43000)
libiconv.so.2 => /miniconda3/envs/djangotest/bin/../lib/libiconv.so.2 (0x00007f28cec5b000)
libicui18n.so.58 => not found
libicuuc.so.58 => not found
libicudata.so.58 => not found
libutil.so.1 => /lib64/libutil.so.1 (0x00007f28cea58000)
librt.so.1 => /lib64/librt.so.1 (0x00007f28ce850000)
libcrypt.so.1 => /lib64/libcrypt.so.1 (0x00007f28ce619000)
libc.so.6 => /lib64/libc.so.6 (0x00007f28ce285000)
/lib64/ld-linux-x86-64.so.2 (0x00007f28cfe75000)
libicuuc.so.64 => /miniconda3/envs/djangotest/bin/../lib/./libicuuc.so.64 (0x00007f28ce0ae000)
libfreebl3.so => /lib64/libfreebl3.so (0x00007f28cdeab000)
libicudata.so.64 => /miniconda3/envs/djangotest/bin/../lib/././libicudata.so.64 (0x00007f28cc467000)
libstdc++.so.6 => /miniconda3/envs/djangotest/bin/../lib/././libstdc++.so.6 (0x00007f28cc2f3000)
libgcc_s.so.1 => /miniconda3/envs/djangotest/bin/../lib/././libgcc_s.so.1 (0x00007f28cff62000)
出现这个问题的原因:缺失pyicu模块导致,pyicu模块是python国际化模块,所以出现上述问题后需要安装pyicu,然后将对应的库链接到lib64文件夹下
#使用conda安装在虚拟环境下
$ conda install pyicu
安装完毕后,进入自己虚拟环境的lib文件夹下,比如我新建的conda虚拟环境名称叫djangotest,先进入miniconda安装目录,进入envs文件夹下,就能看到自己的虚拟环境文件夹,进入文件夹下的lib文件夹:
$ cd /miniconda3/envs/djangotest/lib
$ ls
可以看到libicui18n.so.64
,libicudata.so.64
, libicuuc.so.64
三个文件,将这三个文件软连接到/lib64文件夹下(我的是64位机):
$ ln -s /miniconda3/envs/djangotest/lib/libicui18n.so.64 /lib64/libicui18n.so.58
$ ln -s /miniconda3/envs/djangotest/lib/libicuuc.so.64 /lib64/libicuuc.so.58
$ ln -s /miniconda3/envs/djangotest/lib/libicudata.so.64 /lib64/libicudata.so.58
运行成功:
detected binary path: /miniconda3/envs/djangotest/bin/uwsgi
uWSGI running as root, you can use --uid/--gid/--chroot options
*** WARNING: you are running uWSGI as root !!! (use the --uid flag) ***
chdir() to /quchangtest/quchangtjutest/quchangtjutest
your memory page size is 4096 bytes
detected max file descriptor number: 1048576
lock engine: pthread robust mutexes
thunder lock: disabled (you can enable it with --thunder-lock)
uwsgi socket 0 bound to TCP address 127.0.0.1:8000 fd 3
uWSGI running as root, you can use --uid/--gid/--chroot options
*** WARNING: you are running uWSGI as root !!! (use the --uid flag) ***
Python version: 3.7.1 | packaged by conda-forge | (default, Nov 13 2018, 18:33:04) [GCC 7.3.0]
*** Python threads support is disabled. You can enable it with --enable-threads ***
Python main interpreter initialized at 0x55d2332ec520
uWSGI running as root, you can use --uid/--gid/--chroot options
*** WARNING: you are running uWSGI as root !!! (use the --uid flag) ***
your server socket listen backlog is limited to 100 connections
your mercy for graceful operations on workers is 60 seconds
mapped 656280 bytes (640 KB) for 8 cores
*** Operational MODE: preforking ***
WSGI app 0 (mountpoint='') ready in 0 seconds on interpreter 0x55d2332ec520 pid: 1164 (default app)
uWSGI running as root, you can use --uid/--gid/--chroot options
*** WARNING: you are running uWSGI as root !!! (use the --uid flag) ***
*** uWSGI is running in multiple interpreter mode ***
spawned uWSGI master process (pid: 1164)
spawned uWSGI worker 1 (pid: 1165, cores: 1)
spawned uWSGI worker 2 (pid: 1166, cores: 1)
spawned uWSGI worker 3 (pid: 1167, cores: 1)
spawned uWSGI worker 4 (pid: 1168, cores: 1)
spawned uWSGI worker 5 (pid: 1169, cores: 1)
spawned uWSGI worker 6 (pid: 1170, cores: 1)
spawned uWSGI worker 7 (pid: 1171, cores: 1)
spawned uWSGI worker 8 (pid: 1172, cores: 1)