簡體   English   中英

如何在 mac os x 上將 gunicorn 與 python3.8 而不是 python3.9 一起使用?

[英]How can I use gunicorn with python3.8 instead of python3.9 on mac os x?

我正在嘗試使用 Gunicorn 為 mac os X 上的簡單 python3 應用程序提供 WSGI 服務器,但它使用的是 python2。 我嘗試安裝 gunicorn:

pip install gunicorn

pip3 install gunicorn

這有效但是當我嘗試運行 gunicorn 時出現“找不到命令”錯誤(例如使用gunicorn -w 4 echo:app )。 我還嘗試使用 pip 和 pip3 和 brew 安裝 gunicorn3,但每個都出現錯誤。 我能夠使用以下命令安裝和運行 gunicorn:

easy_install gunicorn

但是,它似乎正在運行 python2。 我試過

easy_install gunicorn3

但出現錯誤。 如何在 Mac OS X 上將 gunicorn 與 python3 一起使用?

編輯:我完全錯誤地認為我看到的錯誤是由於使用 python2。 它實際上運行的是 3.9,這會產生問題,因為缺少太多包。 我早些時候恢復到 python 3.8。 有沒有辦法讓 gunicorn 也使用 python3.8? 我看到的錯誤是:

Traceback (most recent call last):
  File "/usr/local/bin/gunicorn", line 33, in <module>
    sys.exit(load_entry_point('gunicorn==20.0.4', 'console_scripts', 'gunicorn')())
  File "/usr/local/bin/gunicorn", line 22, in importlib_load_entry_point
    for entry_point in distribution(dist_name).entry_points
  File "/usr/local/Cellar/python@3.9/3.9.1/Frameworks/Python.framework/Versions/3.9/lib/python3.9/importlib/metadata.py", line 524, in distribution
    return Distribution.from_name(distribution_name)
  File "/usr/local/Cellar/python@3.9/3.9.1/Frameworks/Python.framework/Versions/3.9/lib/python3.9/importlib/metadata.py", line 187, in from_name
    raise PackageNotFoundError(name)
importlib.metadata.PackageNotFoundError: gunicorn

我能夠通過卸載 easy_install 安裝的 egg 來解決這個問題,然后重新啟動終端,然后稍微修改@Aiyush 的答案為:

python3 -m pip install --upgrade --force-reinstall gunicorn

簡單地使用pip install gunicorn似乎不起作用。 我想我需要重新啟動終端才能使幾天前對 ~/.bash_profile 所做的更改生效。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM