Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Gunicorn wont install to virtualenv

I have a Python Django project that I'm serving using Gunicorn.

Gunicorn was installed inside my virtualenv, and was working fine.

I set up an ftpd on my server, and had to change the ownership of the virtualenv folder using chown, to allow an ftp user to remotely access files via ftp.

Since I changed ownership of the folder, Gunicorn will no longer launch. I was getting a permission denied error.

I uninstalled Gunicorn using pip3 uninstall gunicorn, and attempted to reinstall it. Each time I attempt to install it, it ends up in /usr/bin/gunicorn, instead of inside my virtualenv.

I have uninstalled gunicorn, chown'd the folder back to the original user, activated my virtualenv again, and used pip3 install -I gunicorn. Although the install is successful, again, gunicorn ends up in /usr/bin/gunicorn, instead of inside my virtualenv, how it was originally.

Any suggestions as to why this is happening would be greatly appreciated.

like image 751
Scratcha Avatar asked Oct 27 '25 17:10

Scratcha


1 Answers

I ran into the same issue today, and here is how I finally was able to resolve the issue: First remove gunicorn from your requirements.txt file, and uninstall gunicorn and all of your other dependencies with pip. Then nuke your virtual environment, create another virtual environment, and then reinstall gunicorn and along with your other dependencies.

(venv) $ pip uninstall gunicorn

(venv) $ pip uninstall -r requirements.txt

(venv) $ deactivate

$ rm -rf venv

$ python3 -m venv venv

$ source venv/bin/activate

(venv) $ pip install -r requirements.txt

(venv) $ pip install gunicorn

(venv) $ which gunicorn

After running which gunicorn, see if gunicorn is now located in the desired location (the virtual environment instead of /usr/bin/gunicorn).

like image 163
topherPedersen Avatar answered Oct 29 '25 07:10

topherPedersen



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!