How to install Python Package for global use by all users (incl. www-data)

后端 未结 2 1598
轮回少年
轮回少年 2020-12-09 13:58

I thought I throw together a little dirty script on our server (Ubuntu 16.04) that gives me some plain text output from Python.

I want to call the script like this f

相关标签:
2条回答
  • 2020-12-09 14:04

    Run PIP with root user.

    That should fix the problem.

    0 讨论(0)
  • 2020-12-09 14:26

    I recommend that you try the solution that xotihcan posted first as that is the easy way to make most python modules available to all users including www-data. However it doesn't work for every python module. If that doesn't work for you or you just want to install modules for the www-data user only then use the following commands:

    sudo mkdir /var/www/.local
    sudo mkdir /var/www/.cache
    sudo chown www-data.www-data /var/www/.local
    sudo chown www-data.www-data /var/www/.cache
    sudo -H -u www-data pip install CoolProp
    

    I had this same issue trying to make the Python pyro4 module available for the www-data use. There is another way to do it but it involves some even dirtier hackery. For more details check out my question/answer @ How do I properly call a Python Pyro client using PHP and Apache web server?

    0 讨论(0)
提交回复
热议问题