我的主要操作系统是 Windows 10,但我使用 cygwin 作为终端。通过命令安装 uwsgi 时pip3 install uwsgi,失败并显示错误消息“AttributeError: module 'os' has no attribute 'uname'”
3 回答
uWSGI 需要 ac 编译器来构建,使用 platform.uname 的 os.uname 需要在 uwsgiconfig.py 文件中更新。
以下是针对 Windows 10 的修复方法:
cd 到 uwsgi 安装目录并打开 uwsgiconfig.py
对于以下代码行,将 os.uname 替换为 platform.uname:
uwsgi_os = os.uname ()[0] uwsgi_os_k = re.split('[-+_]', os.uname ()[2])[0] uwsgi_os_v = os.uname ()[3] uwsgi_cpu = os.名字()[4]
对此:
uwsgi_os = **platform.uname**()[0]
uwsgi_os_k = re.split('[-+_]', **platform.uname**()[2])[0]
uwsgi_os_v = **platform.uname**()[3]
uwsgi_cpu = **platform.uname**()[4]
使用 cygwin 安装以下软件包,以确保您有可用于 cygwin 终端的 python3 和 gcc,而不仅仅是在 windows 上安装 python。这是一个单独的 python 安装,而不是 Windows 本身。
- 打开windows cmd终端
- cd 到 cygwin64 (或您的安装目录)
运行这个命令: setup-x86_64.exe -q -P wget -P gcc-g++ -P gcc-core -P gcc-g++ -P libcrypt-devel -P libintl-devel -P python3 -P python3-devel
此命令应为 Cygwin64 安装以下软件包: gcc-core gcc-g++ libcrypt-devel libintl-devel python3 python3-devel
- 在 Cygwin 终端窗口中
- cd 到 uwsgi 目录
- 键入并运行命令'python3 setup.py install'
- 等待这个完成并做一个快乐的舞蹈。
如果你得到:
core/event.c: In function ‘event_queue_read’: core/event.c:1416:9: error: ‘UWSGI_EVENT_IN’ undeclared
可能你没有用 cygwin python 开始安装
代码需要稍微修改一下:
import platform
uwsgi_os = platform.uname()[0]
uwsgi_os_k = re.split('[-+_]', platform.uname()[2])[0]
uwsgi_os_v = platform.uname()[3]
uwsgi_cpu = platform.uname()[4]