Forums

Installing packages using package manager in PythonAnywhere

I have migrated, configured and launched my Flask REST Api and database on my PythonAnywhere server. Now I am in process of deploying the web application. For convenience reasons, I want to host it on the same server.

The application itself is a React application which when built with npx build results in a static application, however this must be served by a web server as we all know.

My server of choice is Nginx. It is fast, powerful, helps with load balancing, helps with all sorts of monitoring etc. I have my config files all set up so it would be a shame to not be able to deploy my web app to the nginx server.

I tried installing nginx using sudo apt-get install nginx but it wouldnt let me - presumably sudo is not recognized as a command. Then I tried it without sudo and no wonder I got an error 13 - permission denied. I cannot do much on my part here, I would appreciate the help of the admins who might have root access to these servers.

Regarding installing packages-- the short answer is you need to install into your homedir. eg: for python installs this involves using a --user flag or setting up a virtualenv within your homedir.

Regarding hosting a static react page-- there are a bunch of reasons why your setup wouldn't work. First, we actually already have nginx setup, and also say you were to run something from the console-- other people outside of PythonAnywhere on the external internet would not be able to access that (they would be blocked).

Thankfully, there is an easily solution, where we do everything for you. See this!