简体   繁体   中英

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/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

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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM