解决Linux下安装gunicorn提示-bash: gunicorn: command not found

版权声明:本文为博主原创文章,遵循 CC 4.0 BY-SA 版权协议,转载请附上原文出处链接和本声明。
本文链接:https://blog.csdn.net/jiduochou963/article/details/88784947

我在CentOS7下安装Python3之后踩坑:

[root@localhost ~]# pip3 install httpbin
[root@localhost ~]# pip3 install gunicorn
[root@localhost ~]# pip list
Package      Version 
------------ --------
...
gunicorn     19.9.0  
httpbin      0.7.0   
...
[root@localhost ~]# 
[root@localhost ~]# gunicorn
-bash: gunicorn: 未找到命令
[root@localhost ~]# 

解决办法

新建虚拟环境,在虚拟环境里面:

[root@localhost bin]# mkvirtualenv Py3_dev
Using base prefix '/usr/local/python3'
New python executable in /root/.virtualenvs/Py3_dev/bin/python3.7
Also creating executable in /root/.virtualenvs/Py3_dev/bin/python
Installing setuptools, pip, wheel...
done.
virtualenvwrapper.user_scripts creating /root/.virtualenvs/Py3_dev/bin/predeactivate
virtualenvwrapper.user_scripts creating /root/.virtualenvs/Py3_dev/bin/postdeactivate
virtualenvwrapper.user_scripts creating /root/.virtualenvs/Py3_dev/bin/preactivate
virtualenvwrapper.user_scripts creating /root/.virtualenvs/Py3_dev/bin/postactivate
virtualenvwrapper.user_scripts creating /root/.virtualenvs/Py3_dev/bin/get_env_details
(Py3_dev) [root@localhost bin]#
(Py3_dev) [root@localhost ~]# pip3 install httpbin
...
(Py3_dev) [root@localhost ~]# pip3 install gunicorn
...
(Py3_dev) [root@localhost ~]# gunicorn
usage: gunicorn [OPTIONS] [APP_MODULE]
gunicorn: error: No application module specified.
(Py3_dev) [root@localhost ~]# gunicorn -b :80 httpbin:app
[2019-03-24 23:52:27 +0800] [18686] [INFO] Starting gunicorn 19.9.0
[2019-03-24 23:52:27 +0800] [18686] [INFO] Listening at: http://0.0.0.0:80 (18686)
[2019-03-24 23:52:27 +0800] [18686] [INFO] Using worker: sync
[2019-03-24 23:52:27 +0800] [18690] [INFO] Booting worker with pid: 18690
[2019-03-24 23:53:11 +0800] [18686] [CRITICAL] WORKER TIMEOUT (pid:18690)
[2019-03-24 23:53:11 +0800] [18690] [INFO] Worker exiting (pid: 18690)
[2019-03-24 23:53:11 +0800] [18727] [INFO] Booting worker with pid: 18727
^C[2019-03-24 23:53:29 +0800] [18686] [INFO] Handling signal: int
[2019-03-24 23:53:29 +0800] [18727] [INFO] Worker exiting (pid: 18727)
[2019-03-24 23:53:30 +0800] [18686] [INFO] Shutting down: Master
(Py3_dev) [root@localhost ~]# 
后记

我也没搞清楚为啥只是在虚拟环境里面能成功。。。欢迎评论指出原因,感谢。

后记:
可以参考: Mac安装gunicorn成功,却无系统命令 https://blog.csdn.net/cq1113/article/details/78531688


推荐阅读:

python明明pip安装成功却找不到包 https://blog.csdn.net/qq_36376711/article/details/86292199
pip装了一个包,但是python里Import的时候找不到怎么办? https://blog.csdn.net/myknotruby/article/details/78911452
python pip 安装包后提示找不到的问题的解决 https://blog.csdn.net/u012955491/article/details/19782539/
Mac安装gunicorn成功,却无系统命令 https://blog.csdn.net/cq1113/article/details/78531688


展开阅读全文

没有更多推荐了,返回首页