'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.



Solution 1:[1]

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).

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1