Python教程

ubuntu 同时安装python2 和 python3 版本的 gunicorn

本文主要是介绍ubuntu 同时安装python2 和 python3 版本的 gunicorn,对大家解决编程问题具有一定的参考价值,需要的程序猿们随着小编来一起学习吧!

前言

最近在学习使用 gunicorn 部署 flask 项目。发现使用 pip3 安装完 gunicorn后,如如果再使用 pip2 安装 gunicorn,后安装的 gunicorn 就会覆盖掉原来的,现在将我的解决方案记录一下,留作参考使用。

解决方案

  1. 卸载全部 gunicorn
    pip2 uninstall gunicorn
    pip3 uninstall gunicorn

  2. 安装 python3 版本的 gunicorn
    (1). pip3 install gunicorn
    (2). 使用 whereis gunicorn 找到 gunicorn 的位置,我的是在 /usr/local/bin/gunicorn.
    (3). 然后进入到这个目录,重命名 gunicorn: mv gunicorn gunicorn3
    (4). 在终端输入gunicorn3 -h,调用成功,即表示更改成功

  3. 安装 python2 版本的 gunicorn
    (1). pip2 install gunicorn
    (2). 安装完成后,会发现输入 gunicorn + Tab键,gunicorn、gunicorn3同时存在
    (3). 在终端输入gunicorn -h,调用成功,即表示安装成功

至此,全部安装完毕,使用 gunicorn3 默认调用 python3,使用 gunicorn 默认调用 python2
注:如果重新安装python2 的 pip 工具,可以参考https://www.cnblogs.com/brian-sun/p/14549474.html

这篇关于ubuntu 同时安装python2 和 python3 版本的 gunicorn的文章就介绍到这儿,希望我们推荐的文章对大家有所帮助,也希望大家多多支持为之网!