安装uwsgi报错
执行pip3 install uwsgi后报错Building wheel for uwsgi (setup.py) ... errorERROR: Command errored out with exit status 1:command: /usr/bin/python3 -u -c 'import sys, setuptools, tokenize; sys.argv[0] = '"'"'
ubuntu执行pip3 install uwsgi后报错。
CentOS7执行pip3 install uwsgi也报这个错,所以当时又尝试yum install uwsgi,没报错,应该是装的时候依赖已经都装好了。但后来发现,这个用yum安装的uwsgi,用它启动flask项目后,访问项目报错Internal Server Error,把项目复制到别人服务器却能正常访问,怀疑是因为不能用yum安装的uwsgi,而且还遇到ps -ef | grep uwsgi显示的进程号与uwsgi.pid文件(uwsgi.ini里配置的)中的不一致,所以卸载了yum安装的uwsgi,然后尝试各种修改后还是报Internal Server Error,没办法了直接重置服务器,并且换成了CentOS 8.2,执行pip install uwsgi还是报这个错。
Building wheel for uwsgi (setup.py) ... error
ERROR: Command errored out with exit status 1:
command: /usr/bin/python3 -u -c 'import sys, setuptools, tokenize; sys.argv[0] = '"'"'/tmp/pip-install-k8k02_sl/uwsgi/setup.py'"'"'; __file__='"'"'/tmp/pip-install-k8k02_sl/uwsgi/setup.py'"'"';f=getattr(tokenize, '"'"'open'"'"', open)(__file__);code=f.read().replace('"'"'\r\n'"'"', '"'"'\n'"'"');f.close();exec(compile(code, __file__, '"'"'exec'"'"'))' bdist_wheel -d /tmp/pip-wheel-a7zocrcr
cwd: /tmp/pip-install-k8k02_sl/uwsgi/
Complete output (102 lines):
/usr/lib/python3.8/distutils/dist.py:274: UserWarning: Unknown distribution option: 'descriptions'
warnings.warn(msg)
running bdist_wheel
running build
running build_py
creating build
creating build/lib
copying uwsgidecorators.py -> build/lib
installing to build/bdist.linux-x86_64/wheel
running install
using profile: buildconf/default.ini
detected include path: ['/usr/lib/gcc/x86_64-linux-gnu/9/include', '/usr/local/include', '/usr/include/x86_64-linux-gnu', '/usr/include']
Patching "bin_name" to properly install_scripts dir
detected CPU cores: 4
configured CFLAGS: -O2 -I. -Wall -D_LARGEFILE_SOURCE -D_FILE_OFFSET_BITS=64 -Wextra -Wno-unused-parameter -Wno-missing-field-initializers -DUWSGI_HAS_IFADDRS -DUWSGI_ZLIB -DUWSGI_LOCK_USE_MUTEX -DUWSGI_EVENT_USE_EPOLL -DUWSGI_EVENT_TIMER_USE_TIMERFD -DUWSGI_EVENT_FILEMONITOR_USE_INOTIFY -DUWSGI_PCRE -DUWSGI_ROUTING -DUWSGI_VERSION="\"2.0.19.1\"" -DUWSGI_VERSION_BASE="2" -DUWSGI_VERSION_MAJOR="0" -DUWSGI_VERSION_MINOR="19" -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(ugreen);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(ugreen);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][x86_64-linux-gnu-gcc -pthread] core/utils.o
[thread 2][x86_64-linux-gnu-gcc -pthread] core/protocol.o
[thread 3][x86_64-linux-gnu-gcc -pthread] core/socket.o
[thread 0][x86_64-linux-gnu-gcc -pthread] core/logging.o
[thread 2][x86_64-linux-gnu-gcc -pthread] core/master.o
[thread 0][x86_64-linux-gnu-gcc -pthread] core/master_utils.o
[thread 3][x86_64-linux-gnu-gcc -pthread] core/emperor.o
[thread 2][x86_64-linux-gnu-gcc -pthread] core/notify.o
[thread 2][x86_64-linux-gnu-gcc -pthread] core/mule.o
[thread 0][x86_64-linux-gnu-gcc -pthread] core/subscription.o
[thread 2][x86_64-linux-gnu-gcc -pthread] core/stats.o
[thread 1][x86_64-linux-gnu-gcc -pthread] core/sendfile.o
[thread 3][x86_64-linux-gnu-gcc -pthread] core/async.o
[thread 1][x86_64-linux-gnu-gcc -pthread] core/master_checks.o
[thread 2][x86_64-linux-gnu-gcc -pthread] core/fifo.o
[thread 0][x86_64-linux-gnu-gcc -pthread] core/offload.o
[thread 3][x86_64-linux-gnu-gcc -pthread] core/io.o
[thread 1][x86_64-linux-gnu-gcc -pthread] core/static.o
[thread 2][x86_64-linux-gnu-gcc -pthread] core/websockets.o
[thread 0][x86_64-linux-gnu-gcc -pthread] core/spooler.o
[thread 2][x86_64-linux-gnu-gcc -pthread] core/snmp.o
[thread 1][x86_64-linux-gnu-gcc -pthread] core/exceptions.o
[thread 0][x86_64-linux-gnu-gcc -pthread] core/config.o
[thread 2][x86_64-linux-gnu-gcc -pthread] core/setup_utils.o
[thread 3][x86_64-linux-gnu-gcc -pthread] core/clock.o
[thread 1][x86_64-linux-gnu-gcc -pthread] core/init.o
[thread 3][x86_64-linux-gnu-gcc -pthread] core/buffer.o
[thread 2][x86_64-linux-gnu-gcc -pthread] core/reader.o
[thread 1][x86_64-linux-gnu-gcc -pthread] core/writer.o
[thread 0][x86_64-linux-gnu-gcc -pthread] core/alarm.o
[thread 3][x86_64-linux-gnu-gcc -pthread] core/cron.o
[thread 2][x86_64-linux-gnu-gcc -pthread] core/hooks.o
[thread 3][x86_64-linux-gnu-gcc -pthread] core/plugins.o
[thread 0][x86_64-linux-gnu-gcc -pthread] core/lock.o
[thread 1][x86_64-linux-gnu-gcc -pthread] core/cache.o
[thread 2][x86_64-linux-gnu-gcc -pthread] core/daemons.o
[thread 3][x86_64-linux-gnu-gcc -pthread] core/errors.o
[thread 0][x86_64-linux-gnu-gcc -pthread] core/hash.o
[thread 3][x86_64-linux-gnu-gcc -pthread] core/master_events.o
[thread 0][x86_64-linux-gnu-gcc -pthread] core/chunked.o
[thread 2][x86_64-linux-gnu-gcc -pthread] core/queue.o
[thread 3][x86_64-linux-gnu-gcc -pthread] core/event.o
[thread 0][x86_64-linux-gnu-gcc -pthread] core/signal.o
[thread 2][x86_64-linux-gnu-gcc -pthread] core/strings.o
[thread 1][x86_64-linux-gnu-gcc -pthread] core/progress.o
[thread 3][x86_64-linux-gnu-gcc -pthread] core/timebomb.o
[thread 0][x86_64-linux-gnu-gcc -pthread] core/ini.o
[thread 1][x86_64-linux-gnu-gcc -pthread] core/fsmon.o
[thread 3][x86_64-linux-gnu-gcc -pthread] core/mount.o
[thread 2][x86_64-linux-gnu-gcc -pthread] core/metrics.o
[thread 0][x86_64-linux-gnu-gcc -pthread] core/plugins_builder.o
[thread 1][x86_64-linux-gnu-gcc -pthread] core/sharedarea.o
[thread 3][x86_64-linux-gnu-gcc -pthread] core/rpc.o
[thread 0][x86_64-linux-gnu-gcc -pthread] core/gateway.o
[thread 3][x86_64-linux-gnu-gcc -pthread] core/loop.o
[thread 0][x86_64-linux-gnu-gcc -pthread] core/cookie.o
[thread 1][x86_64-linux-gnu-gcc -pthread] core/querystring.o
[thread 3][x86_64-linux-gnu-gcc -pthread] core/rb_timers.o
[thread 2][x86_64-linux-gnu-gcc -pthread] core/transformations.o
[thread 0][x86_64-linux-gnu-gcc -pthread] core/uwsgi.o
[thread 1][x86_64-linux-gnu-gcc -pthread] proto/base.o
[thread 2][x86_64-linux-gnu-gcc -pthread] proto/uwsgi.o
[thread 3][x86_64-linux-gnu-gcc -pthread] proto/http.o
[thread 1][x86_64-linux-gnu-gcc -pthread] proto/fastcgi.o
[thread 2][x86_64-linux-gnu-gcc -pthread] proto/scgi.o
[thread 2][x86_64-linux-gnu-gcc -pthread] proto/puwsgi.o
[thread 1][x86_64-linux-gnu-gcc -pthread] lib/linux_ns.o
[thread 2][x86_64-linux-gnu-gcc -pthread] core/zlib.o
[thread 3][x86_64-linux-gnu-gcc -pthread] core/regexp.o
[thread 1][x86_64-linux-gnu-gcc -pthread] core/routing.o
[thread 2][x86_64-linux-gnu-gcc -pthread] core/yaml.o
[thread 3][x86_64-linux-gnu-gcc -pthread] core/dot_h.o
[thread 3][x86_64-linux-gnu-gcc -pthread] core/config_py.o
*** uWSGI compiling embedded plugins ***
[thread 3][x86_64-linux-gnu-gcc -pthread] plugins/python/python_plugin.o
[thread 2][x86_64-linux-gnu-gcc -pthread] plugins/python/pyutils.o
In file included from plugins/python/python_plugin.c:1:
plugins/python/uwsgi_python.h:2:10: fatal error: Python.h: 没有那个文件或目录
2 | #include <Python.h>
| ^~~~~~~~~~
compilation terminated.
In file included from plugins/python/pyutils.c:1:
plugins/python/uwsgi_python.h:2:10: fatal error: Python.h: 没有那个文件或目录
2 | #include <Python.h>
| ^~~~~~~~~~
compilation terminated.
----------------------------------------
ERROR: Failed building wheel for uwsgi
Running setup.py clean for uwsgi
Failed to build uwsgi
Installing collected packages: uwsgi
Running setup.py install for uwsgi ... error
ERROR: Command errored out with exit status 1:
command: /usr/bin/python3 -u -c 'import sys, setuptools, tokenize; sys.argv[0] = '"'"'/tmp/pip-install-k8k02_sl/uwsgi/setup.py'"'"'; __file__='"'"'/tmp/pip-install-k8k02_sl/uwsgi/setup.py'"'"';f=getattr(tokenize, '"'"'open'"'"', open)(__file__);code=f.read().replace('"'"'\r\n'"'"', '"'"'\n'"'"');f.close();exec(compile(code, __file__, '"'"'exec'"'"'))' install --record /tmp/pip-record-ey_zf81p/install-record.txt --single-version-externally-managed --user --prefix= --compile --install-headers /home/ubuntu/.local/include/python3.8/uwsgi
cwd: /tmp/pip-install-k8k02_sl/uwsgi/
Complete output (107 lines):
/usr/lib/python3.8/distutils/dist.py:274: UserWarning: Unknown distribution option: 'descriptions'
warnings.warn(msg)
running install
using profile: buildconf/default.ini
detected include path: ['/usr/lib/gcc/x86_64-linux-gnu/9/include', '/usr/local/include', '/usr/include/x86_64-linux-gnu', '/usr/include']
Patching "bin_name" to properly install_scripts dir
detected CPU cores: 4
configured CFLAGS: -O2 -I. -Wall -D_LARGEFILE_SOURCE -D_FILE_OFFSET_BITS=64 -Wextra -Wno-unused-parameter -Wno-missing-field-initializers -DUWSGI_HAS_IFADDRS -DUWSGI_ZLIB -DUWSGI_LOCK_USE_MUTEX -DUWSGI_EVENT_USE_EPOLL -DUWSGI_EVENT_TIMER_USE_TIMERFD -DUWSGI_EVENT_FILEMONITOR_USE_INOTIFY -DUWSGI_PCRE -DUWSGI_ROUTING -DUWSGI_VERSION="\"2.0.19.1\"" -DUWSGI_VERSION_BASE="2" -DUWSGI_VERSION_MAJOR="0" -DUWSGI_VERSION_MINOR="19" -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(ugreen);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(ugreen);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 ***
core/utils.o is up to date
core/protocol.o is up to date
core/socket.o is up to date
core/logging.o is up to date
core/master.o is up to date
core/master_utils.o is up to date
core/emperor.o is up to date
core/notify.o is up to date
core/mule.o is up to date
core/subscription.o is up to date
core/stats.o is up to date
core/sendfile.o is up to date
core/async.o is up to date
core/master_checks.o is up to date
core/fifo.o is up to date
core/offload.o is up to date
core/io.o is up to date
core/static.o is up to date
core/websockets.o is up to date
core/spooler.o is up to date
core/snmp.o is up to date
core/exceptions.o is up to date
core/config.o is up to date
core/setup_utils.o is up to date
core/clock.o is up to date
core/init.o is up to date
core/buffer.o is up to date
core/reader.o is up to date
core/writer.o is up to date
core/alarm.o is up to date
core/cron.o is up to date
core/hooks.o is up to date
core/plugins.o is up to date
core/lock.o is up to date
core/cache.o is up to date
core/daemons.o is up to date
core/errors.o is up to date
core/hash.o is up to date
core/master_events.o is up to date
core/chunked.o is up to date
core/queue.o is up to date
core/event.o is up to date
core/signal.o is up to date
core/strings.o is up to date
core/progress.o is up to date
core/timebomb.o is up to date
core/ini.o is up to date
core/fsmon.o is up to date
core/mount.o is up to date
core/metrics.o is up to date
core/plugins_builder.o is up to date
core/sharedarea.o is up to date
core/rpc.o is up to date
core/gateway.o is up to date
core/loop.o is up to date
core/cookie.o is up to date
core/querystring.o is up to date
core/rb_timers.o is up to date
core/transformations.o is up to date
core/uwsgi.o is up to date
proto/base.o is up to date
proto/uwsgi.o is up to date
proto/http.o is up to date
proto/fastcgi.o is up to date
proto/scgi.o is up to date
proto/puwsgi.o is up to date
lib/linux_ns.o is up to date
core/zlib.o is up to date
core/regexp.o is up to date
core/routing.o is up to date
core/yaml.o is up to date
[thread 3][x86_64-linux-gnu-gcc -pthread] core/dot_h.o
[thread 1][x86_64-linux-gnu-gcc -pthread] core/config_py.o
*** uWSGI compiling embedded plugins ***
[thread 2][x86_64-linux-gnu-gcc -pthread] plugins/python/python_plugin.o
[thread 0][x86_64-linux-gnu-gcc -pthread] plugins/python/pyutils.o
[thread 1][x86_64-linux-gnu-gcc -pthread] plugins/python/pyloader.o
[thread 3][x86_64-linux-gnu-gcc -pthread] plugins/python/wsgi_handlers.o
In file included from plugins/python/python_plugin.c:1:
plugins/python/uwsgi_python.h:2:10: fatal error: Python.h: 没有那个文件或目录
2 | #include <Python.h>
| ^~~~~~~~~~
compilation terminated.
In file included from plugins/python/pyutils.c:1:
plugins/python/uwsgi_python.h:2:10: fatal error: Python.h: 没有那个文件或目录
2 | #include <Python.h>
| ^~~~~~~~~~
compilation terminated.
In file included from plugins/python/wsgi_handlers.c:1:
plugins/python/uwsgi_python.h:2:10: fatal error: Python.h: 没有那个文件或目录
2 | #include <Python.h>
| ^~~~~~~~~~
compilation terminated.
In file included from plugins/python/pyloader.c:1:
plugins/python/uwsgi_python.h:2:10: fatal error: Python.h: 没有那个文件或目录
2 | #include <Python.h>
| ^~~~~~~~~~
compilation terminated.
----------------------------------------
ERROR: Command errored out with exit status 1: /usr/bin/python3 -u -c 'import sys, setuptools, tokenize; sys.argv[0] = '"'"'/tmp/pip-install-k8k02_sl/uwsgi/setup.py'"'"'; __file__='"'"'/tmp/pip-install-k8k02_sl/uwsgi/setup.py'"'"';f=getattr(tokenize, '"'"'open'"'"', open)(__file__);code=f.read().replace('"'"'\r\n'"'"', '"'"'\n'"'"');f.close();exec(compile(code, __file__, '"'"'exec'"'"'))' install --record /tmp/pip-record-ey_zf81p/install-record.txt --single-version-externally-managed --user --prefix= --compile --install-headers /home/ubuntu/.local/include/python3.8/uwsgi Check the logs for full command output.
首先,ubuntu最好执行一下sudo apt-get update,防止一会儿安装失败提示让执行这个;CentOS 8.2最好执行一下yum upgrade和yum update,否则接下来的安装可能报错,或者提示没这个软件包。
是因为没有python
的头文件,也就是说没有安装python
的开发库。
ubuntu:
sudo apt-get install python-dev python3-dev,ubuntu20.04自带python3,所以只需安python3-dev,然后再pip3 install uwsgi。参考链接
如果还报错,再执行sudo apt-get install gcc,然后再安装。
CentOS 8.2(腾讯云):
yum install python3-devel,注意和ubuntu里装的不一样,再pip install uwsgi。
CentOS 8.3(虚拟机无桌面版,安装系统时选的最小安装):
先yum install python36(一开始只输了python,提示有python2,python36,python38),然后是上面8.2的两步,做完还是报错了,于是再dnf -y install gcc gcc-c++ zlib-devel bzip2-devel openssl-devel sqlite-devel readline-devel libffi-devel,然后pip3 install uwsgi。那一长串依赖的参考链接。若提示没有dnf命令,执行yum install dnf -y安装dnf软件包管理器,参考链接。
CentOS 7.9.2009(腾讯云):
我用了Miniconda,虚拟环境是python3.6,conda创建虚拟环境后实际创建的是python3.6.2。关于Miniconda,详情可看我的另一篇文章。若执行以下代码安装失败,看文末的总结。
conda create -n flask_blog python=3.6 # 装好后实际是3.6.2,可在装好后进入虚拟环境输入python查看python版本
conda activate flask_blog
yum install python3-devel # 装的是python3-devel 3.6.8-18.el7
pip install uwsgi
CentOS 7.9.2009(官网DVD镜像) :
由于没有自带python3,所以需要手动安装,需要python3的原因在文末的总结中,这里我依然使用Miniconda。
conda create -n flask_blog python=3.6 # 装3.7最终安装uwsgi也成功
conda activate flask_blog
# yum install python3 # 装的是python 3.6.8-18.el7,后来发现不装也行,因虚拟环境已经是python3.6,conda创建的具体版本是3.6.2,虚拟环境若是python3.7时同理不装也行
yum install python3-devel # 装的是python3-devel 3.6.8-18.el7
pip3 install uwsgi
总结
只针对CentOS 7.9.2009,先不考虑其他依赖(因系统可能已自带),uwsgi_2.0.20版(测试时默认下载的版本)需python3.6或python3.7环境,3.8和3.9截止到测试时不行,即uwsgi所在的环境(如虚拟环境)中需已安装python3.6或python3.7,然后执行yum install python3-devel,再pip3 install uwsgi。
得到结论的测试过程:
首先下载CentOS 7.9.2009 DVD镜像,我是在阿里云开源镜像站下载的,你也可以在CentOS官网选择其他镜像站。
然后安装到虚拟机,安装完成后拍摄快照1。
切换root用户(因安装软件需root用户),下载Miniconda,下载完成后终端不要关(方便恢复快照后直接在当前终端安装),拍摄快照2。
第一轮测试
恢复快照1
切换root,因安装软件需root用户
yum install python3 # 装的是python 3.6.8-18.el7,CentOS 7.9.2009未自带python3,所以需手动安装
yum install python3-devel # 装的是python3-devel 3.6.8-18.el7
pip3 install uwsgi # 成功
由于之前CentOS 8.2(腾讯云)时已经写了要装python3-devel,所以我又执行了
恢复快照1
切换root,因安装软件需root用户
yum install python3-devel # 装的是python3-devel 3.6.8-18.el7
pip3 install uwsgi # 成功
即相较于上一次,这次不手动装python3,结果uwsgi也安装成功,因安装python3-devel时顺带装了python3,如后文图3。
说明uwsgi_2.0.20版(测试时默认下载的版本)需python3环境和python3-devel,其他可能需要的依赖在系统中已自带,注意这里仅针对CentOS 7.9.2009 DVD镜像。
附上一些截图,是执行命令后具体安装的内容
yum install python3
执行上一步后再yum install python3-devel
不手动装python3,直接yum install python3-devel,此时安装的数量比图2多
第二轮测试
在第二轮测试之前,其实我已经用Miniconda的python3.9尝试安装uwsgi了,结果失败,然后才做了第一轮测试,结果第一轮测试成功,说明失败的原因可能是python版本不支持,所以第二轮测试要测试不同的python版本。
本轮需要测试多次,测试思路是这样的:
- 恢复快照2
- 安装Miniconda,安装完成后重启终端,再切换root用户
- Miniconda创建不同于上次测试使用的python环境,每次测试只创建一个虚拟环境,总共测了5次,分别是python3.6、3.7、3.8、3.9,还有一次是第一次默认base环境的python3.9,因测试时Miniconda自带python3.9
- yum install python3
- yum install python3-devel
- pip3 install uwsgi
第一次测试,注意本次使用的miniconda的默认base环境
恢复快照2
安装miniconda,安装完成后重启终端,再切换root用户
yum install python3 # 装的是python 3.6.8-18.el7
yum install python3-devel # 装的是python3-devel 3.6.8-18.el7
pip3 install uwsgi # 报错
第二次测试
恢复快照2
安装miniconda,安装完成后重启终端,再切换root用户
conda create -n flask_blog python=3.9
conda activate flask_blog
yum install python3 # 装的是python 3.6.8-18.el7
yum install python3-devel # 装的是python3-devel 3.6.8-18.el7
pip3 install uwsgi # 报错
第三次测试
同第二次,只是python虚拟环境换成3.8,最终安装uwsgi依然报错
第四次测试
恢复快照2
安装miniconda,安装完成后重启终端,再切换root用户
conda create -n flask_blog python=3.6
conda activate flask_blog
yum install python3 # 装的是python 3.6.8-18.el7
yum install python3-devel # 装的是python3-devel 3.6.8-18.el7
pip3 install uwsgi
第五次测试
同第四次,只是python虚拟环境换成3.7,最终安装uwsgi也成功
在测试了python3.9、3.8都失败时,我没接着去测试python3.7,而是测试了python3.6,因为这时才发现前文中的图1和图2的内容,即yum install python3和yum install python3-devel安装的都是3.6.8-18.el7,所以先测试了python3.6,成功了,然后再测的python3.7。
说一下yum install python3和Miniconda(测试时默认最新版)创建虚拟环境python=3.6的区别:
- yum install python3装的是python3.6.8
- conda create -n flask_blog python=3.6装好后实际是3.6.2
可以在安装后在终端输入python查看具体的python版本。
第三轮测试
基于前两轮测试,得到的结论是uwsgi_2.0.20版(测试时默认下载的版本)需python3.6或3.7,及python3-devel,然后我在想,在不同的python版本,是否都需要执行yum install python3?
所以我把第二轮测试中的yum install python3去掉,其他不变,这就是第三轮测试的内容,结果是python3.9、3.8最终安装uwsgi报错,python3.6、3.7最终安装uwsgi成功。
然后才得到总结中的最终结论。
题外话,测试时由于频繁创建虚拟环境(为了保证不出问题,就没有创建虚拟环境后拍快照,而是每次都重新创建),创建时需要下载文件,导致服务器暂时拒绝了我的请求,后续测试无法进行,第二天才接着测试。
总结中未用到的参考链接3,链接里的命令在腾讯云CentOS 7.9.2009执行不了,在官方CentOS 7.9.2009 DVD镜像可以执行。另外官方CentOS 7.9.2009 DVD镜像直接使用我的方法就能安装uwsgi,不用这篇文章的命令。
-总结部分 完-
另外,安装uwsgi时,用pip还是pip3,取决于你当前默认环境是否是python3,若默认是python3,则用pip,若默认是python2,则用pip3。
更多推荐
所有评论(0)