解决uWSGI 启动时ImportError: No module named

ImportError: No module named ipaddress
unable to load app 0 (mountpoint='') (callable not found or import error)
*** no app loaded. going in full dynamic mode ***
*** uWSGI is running in multiple interpreter mode ***
spawned uWSGI master process (pid: 2342)
spawned uWSGI worker 1 (pid: 2354, cores: 1)
spawned uWSGI worker 2 (pid: 2355, cores: 1)

今天在搭建服务运行环境的时候,发现了一个uwsgi报出的导入错误问题,如上看到的,实际上我的系统里已经安装了这个包,但是依然发生了导入错误,第一感觉就是环境变量的问题,所以一顿查涉及到环境变量的文件 .bashrc, .bash_profile, /etc/profile, 都看了,并没有发现什么问题,然后我又具体看一下uwsgi的启动日志,如下:

*** Starting uWSGI 2.0.15 (64bit) on [Fri Apr 26 17:33:55 2019] ***
compiled with version: 4.8.5 20150623 (Red Hat 4.8.5-16) on 08 April 2019 16:38:27
os: Linux-3.10.0-693.el7.x86_64 #1 SMP Tue Aug 22 21:09:27 UTC 2017
nodename: XQ
machine: x86_64
clock source: unix
pcre jit disabled
detected number of CPU cores: 32
current working directory: /export/servers/app/mega
writing pidfile to /tmp/uwsgi.pid
detected binary path: /usr/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 /export/servers/app/mega
your processes number limit is 32768
your memory page size is 4096 bytes
detected max file descriptor number: 65535
lock engine: pthread robust mutexes
thunder lock: disabled (you can enable it with --thunder-lock)
uWSGI http bound on 0.0.0.0:80 fd 4
uwsgi socket 0 bound to TCP address 127.0.0.1:42021 (port auto-assigned) fd 3
Python version: 2.7.5 (default, Aug  4 2017, 00:39:18)  [GCC 4.8.5 20150623 (Red Hat 4.8.5-16)]
Python main interpreter initialized at 0x735fe0
python threads support enabled
your server socket listen backlog is limited to 200 connections
your mercy for graceful operations on workers is 60 seconds
mapped 710080 bytes (693 KB) for 6 cores
*** Operational MODE: preforking ***

发现uwsgi启动的时候用的是Python version: 2.7.5 ,我的系统是CentOS7.4,系统原来默认安装的是虚拟python2.7.5,而我在部署的时候,已经放弃2.7.5而使用2.7.9的版本,所以uwsgi使用的python环境一定不是我自己的环境,再看 detected binary path: /usr/bin/uwsgi ,这是使用uwsgi的路径,然后 我查了一下 uwsgi的位置

find / -name uwsgi
/usr/local/bin/uwsgi 
/usr/bin/uwsgi

发现有两个uwsgi,而uwsgi启动的时候是调用/usr/bin/uwsgi 下的uwsgi,不是我自己安装的 /usr/local/bin/uwsgi ,所以问题找到了,uwsgi的启动文件不正确,导致无法加载我已经安装的环境包,解决方法是删掉/usr/bin/uwsgi,建一个软连接

 ln -s /usr/local/bin/uwsgi /usr/bin/uwsgi

这样就解决问题了。总结一下,公司的CentOS7.4的系统模板(第一次使用),SA是做了自己的一些处理,而这些影响到我的项目启动,有坑没关系,慢慢踩就能踩过了

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值