Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
249 views
in Technique[技术] by (71.8m points)

python - How can I use gunicorn with python3.8 instead of python3.9 on mac os x?

I am trying to use Gunicorn to provide a WSGI server for a simple python3 application on mac os X but it's using python2. I tried installing gunicorn with:

pip install gunicorn

and

pip3 install gunicorn

which worked but I got a "command not found" error when I tried to run gunicorn (for example with gunicorn -w 4 echo:app). I also tried installing gunicorn3 with pip and pip3 and brew but got an error with each. I was able to get gunicorn to install and run using:

easy_install gunicorn

however, it seems to be running python2. I tried

easy_install gunicorn3

but got an error. How can I use gunicorn with python3 on Mac OS X?

Edit: I was completely wrong in thinking the errors I was seeing were due to the use of python2. It's actually running 3.9 which is producing problems since so many packages are missing. I had earlier reverted to python 3.8. Is there a way to get gunicorn to use python3.8 as well? There error I'm seeing is:

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/[email protected]/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/[email protected]/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
question from:https://stackoverflow.com/questions/65924061/how-can-i-use-gunicorn-with-python3-8-instead-of-python3-9-on-mac-os-x

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

I was able to fix this by uninstalling the egg installed by easy_install, then restarting the terminal and then just slightly modifying @Aiyush's answer to be:

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

Simply using pip install gunicorn doesn't appear to work. I think I needed to restart the terminal in order for changes to ~/.bash_profile I had made days earlier to take effect.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...