Windows 下 采用 pip install uwsgi 安装 uwsgi 报错:os没有uname(),本文介绍解决方法。

下载源码

https://pypi.org/project/uWSGI/#files

uwsgi 依赖于 C 编译器 you need a C compiler to build uWSGI,采用 MinGW 安装,并配置 path 变量。

修改/解决

定位到 uwsgiconfig.py 文件中,首先 import platform 后,将 os.unam() 都改为 platform.uname() 即可。

os.uname() 是不支持 windows 系统的。platform 模块是支持任何系统。

安装

Administrator@scloud MINGW64 /d/pythonEnv/uwsgi-2.0.13.1
$ python setup.py install
running install
In file included from core/emperor.c:6:0:
./uwsgi.h:172:24: fatal error: sys/socket.h: No such file or directory
 #include <sys/socket.h>
                        ^
In file included from core/socket.c:1:0:
./uwsgi.h:172:24: fatal error: sys/socket.h: No such file or directory
 #include <sys/socket.h>
                        ^
compilation terminated.
compilation terminated.
In file included from core/master.c:1:0:
./uwsgi.h:172:24: fatal error: sys/socket.h: No such file or directory
 #include <sys/socket.h>
                        ^
compilation terminated.
In file included from core/master_utils.c:1:0:
./uwsgi.h:172:24: fatal error: sys/socket.h: No such file or directory
 #include <sys/socket.h>
                        ^
compilation terminated.
In file included from core/utils.c:1:0:
./uwsgi.h:172:24: fatal error: sys/socket.h: No such file or directory
 #include <sys/socket.h>
                        ^
compilation terminated.
In file included from core/logging.c:2:0:
./uwsgi.h:172:24: fatal error: sys/socket.h: No such file or directory
 #include <sys/socket.h>
                        ^
compilation terminated.
In file included from core/protocol.c:1:0:
./uwsgi.h:172:24: fatal error: sys/socket.h: No such file or directory
 #include <sys/socket.h>
                        ^
compilation terminated.
In file included from core/notify.c:1:0:
./uwsgi.h:172:24: fatal error: sys/socket.h: No such file or directory
 #include <sys/socket.h>
                        ^
compilation terminated.
using profile: buildconf/default.ini
detected include path: ['/usr/include', '/usr/local/include']
Patching "bin_name" to properly install_scripts dir
detected CPU cores: 8
configured CFLAGS: -O2 -I. -Wall -Werror -D_LARGEFILE_SOURCE -D_FILE_OFFSET_BITS=64 -fno-strict-aliasing -Wextra -Wno-unused-parameter -Wno-missing-field-initializers -DUWSGI_IPCSEM_ATEXIT -DUWSGI_EVENT_TIMER_USE_NONE -DUWSGI_EVENT_FILEMONITOR_USE_NONE -DUWSGI_VERSION="\"2.0.13.1\"" -DUWSGI_VERSION_BASE="2" -DUWSGI_VERSION_MAJOR="0" -DUWSGI_VERSION_MINOR="13" -DUWSGI_VERSION_REVISION="1" -DUWSGI_VERSION_CUSTOM="\"\"" -DUWSGI_YAML -DUWSGI_PLUGIN_DIR="\".\"" -DUWSGI_DECLARE_EMBEDDED_PLUGINS="UDEP(python);UDEP(gevent);UDEP(ping);UDEP(cache);UDEP(nagios);UDEP(rrdtool);UDEP(carbon);UDEP(rpc);UDEP(corerouter);UDEP(fastrouter);UDEP(http);UDEP(signal);UDEP(syslog);UDEP(rsyslog);UDEP(logsocket);UDEP(router_uwsgi);UDEP(router_redirect);UDEP(router_basicauth);UDEP(zergpool);UDEP(redislog);UDEP(mongodblog);UDEP(router_rewrite);UDEP(router_http);UDEP(logfile);UDEP(router_cache);UDEP(rawrouter);UDEP(router_static);UDEP(sslrouter);UDEP(spooler);UDEP(cheaper_busyness);UDEP(symcall);UDEP(transformation_tofile);UDEP(transformation_gzip);UDEP(transformation_chunked);UDEP(transformation_offload);UDEP(router_memcached);UDEP(router_redis);UDEP(router_hash);UDEP(router_expires);UDEP(router_metrics);UDEP(transformation_template);UDEP(stats_pusher_socket);" -DUWSGI_LOAD_EMBEDDED_PLUGINS="ULEP(python);ULEP(gevent);ULEP(ping);ULEP(cache);ULEP(nagios);ULEP(rrdtool);ULEP(carbon);ULEP(rpc);ULEP(corerouter);ULEP(fastrouter);ULEP(http);ULEP(signal);ULEP(syslog);ULEP(rsyslog);ULEP(logsocket);ULEP(router_uwsgi);ULEP(router_redirect);ULEP(router_basicauth);ULEP(zergpool);ULEP(redislog);ULEP(mongodblog);ULEP(router_rewrite);ULEP(router_http);ULEP(logfile);ULEP(router_cache);ULEP(rawrouter);ULEP(router_static);ULEP(sslrouter);ULEP(spooler);ULEP(cheaper_busyness);ULEP(symcall);ULEP(transformation_tofile);ULEP(transformation_gzip);ULEP(transformation_chunked);ULEP(transformation_offload);ULEP(router_memcached);ULEP(router_redis);ULEP(router_hash);ULEP(router_expires);ULEP(router_metrics);ULEP(transformation_template);ULEP(stats_pusher_socket);"
*** uWSGI compiling server core ***
[thread 1][gcc] core/utils.o
[thread 2][gcc] core/protocol.o
[thread 3][gcc] core/socket.o
[thread 4][gcc] core/logging.o
[thread 5][gcc] core/master.o
[thread 6][gcc] core/master_utils.o
[thread 7][gcc] core/emperor.o
[thread 0][gcc] core/notify.o

完毕。