python - pip install uwsgi 给出错误:AttributeError:模块'os'没有属性'uname'
问题描述
系统:Windows 10
Python:3.9.5
我正在学习在 Google Cloud 上部署 Flask 应用程序。
我试图安装 uwsgi(在我的 Windows 系统上),如这个 youtube 视频所示。
pip install uwsgi
这个错误来了
(flask) D:\projects\websites\googleHostFlaskApp>pip install uwsgi
Collecting uwsgi
Using cached uWSGI-2.0.19.1.tar.gz (803 kB)
ERROR: Command errored out with exit status 1:
command: 'd:\projects\websites\googlehostflaskapp\env\scripts\python.exe' -c 'import io, os, sys, setuptools, tokenize; sys.argv[0] = '"'"'C:\\Users\\HP\\AppData\\Local\\Temp\\pip-install-93528com\\uwsgi_9bf2ba795b9549d6a9a0d2dfa78cd774\\setup.py'"'"'; __file__='"'"'C:\\Users\\HP\\AppData\\Local\\Temp\\pip-install-93528com\\uwsgi_9bf2ba795b9549d6a9a0d2dfa78cd774\\setup.py'"'"';f = getattr(tokenize, '"'"'open'"'"', open)(__file__) if os.path.exists(__file__) else io.StringIO('"'"'from setuptools import setup; setup()'"'"');code = f.read().replace('"'"'\r\n'"'"', '"'"'\n'"'"');f.close();exec(compile(code, __file__, '"'"'exec'"'"'))' egg_info --egg-base 'C:\Users\HP\AppData\Local\Temp\pip-pip-egg-info-tiy5mnl9'
cwd: C:\Users\HP\AppData\Local\Temp\pip-install-93528com\uwsgi_9bf2ba795b9549d6a9a0d2dfa78cd774\
Complete output (7 lines):
Traceback (most recent call last):
File "<string>", line 1, in <module>
File "C:\Users\HP\AppData\Local\Temp\pip-install-93528com\uwsgi_9bf2ba795b9549d6a9a0d2dfa78cd774\setup.py", line 3, in <module>
import uwsgiconfig as uc
File "C:\Users\HP\AppData\Local\Temp\pip-install-93528com\uwsgi_9bf2ba795b9549d6a9a0d2dfa78cd774\uwsgiconfig.py", line 8, in <module>
uwsgi_os = os.uname()[0]
pi
----------------------------------------
WARNING: Discarding https://files.pythonhosted.org/packages/c7/75/45234f7b441c59b1eefd31ba3d1041a7e3c89602af24488e2a22e11e7259/uWSGI-2.0.19.1.tar.gz#sha256=faa85e053c0b1be4d5585b0858d3a511d2cd10201802e8676060fd0a109e5869 (from https://pypi.org/simple/uwsgi/). Command errored
out with exit status 1: python setup.py egg_info Check the logs for full command output.
我试过的答案:
对于 Windows: 我不确定我们必须将答案中给出的文件放在哪里?
对于 ubuntu:我知道我必须向 python 添加一些开发库,但无法在此处找到正确的库以将其安装在我的 Windows 系统中。
解决方案
安装 UWSGI 并非易事。@Seraph 的回答确实有所帮助,但他错过了一些要点,我最终安装了 UWSGI。
所以这里是完整的步骤,这样你就不必像我一样浪费一天的时间:
安装 Cygwin 下载
(Cygwin 是一个开源工具集合,允许从类似 Linux 的界面在 Windows 操作系统上编译和运行 Unix 或 Linux 应用程序)。
这个 youtube 链接将帮助您下载 Cygwin。你在 cygwin 中需要的包:
gcc-core
gcc-g++
libintl-devel
python3-devel
python38-devel
gettext-devel
(如果它给出了需要 c 编译器的错误,那么 gcc-core会有所帮助,如果它出错:-lintl missing,那么 libintl-devel会有所帮助)
3.打开 Cygwin 应用程序后,您可以按照上面的 youtube 链接,在您的 Windows 系统上成功运行 uwsgi。