skip to Main Content

I am trying to deploy Flask app on Unix system using Apache server.
Referring link

In order to deploy, virtual environment and project needs to be created inside "/var/www/" repository.
While doing this root access is required.

Now in order to install packages for this virtualenv from "/var/www/" location I am using

"sudo pip install package" –> pip does not exists

"pip install package" –> permission denied

Is there any way to accomplish this task.

2

Answers


  1. sudo /usr/bin/python3 -m pip install package

    Login or Signup to reply.
  2. When you have a closer look at the tutorial, you are referring to, there is no mention of installing anything globally with pip.

    Instead, the author of the tutorial uses best practices and creates a virtual environment first.

    There are at least two good reasons for this:

    • your environment is isolated from other packages

    • you do not need root or sudo to install

    So, be sure to follow the instructions, and create a virtual environment first.

    The author does it this way

    $ virtualenv --python=python3 hitme
    

    Then activate it exactly like it is described.

    That all said, you certainly can put your flask app into /var/www, but this is just the author’s preference. You could also put it e.g. in a subfolder of your home directory.

    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search