skip to Main Content

I am running apache superset 0.36 in docker with separate dockers for redis and postgres. While trying to connect to MySQL datasource which is running on host machine, I am getting

ERROR:superset.views.core:Unexpected error No module named ‘pymysql’"

I tried bash to superset container sudo docker run -it superset_superset bash and then pip install pymysql but getting warning

"WARNING: The directory ‘/home/superset/.cache/pip/http’ or its parent directory is not owned by the current user and the cache has been disabled. Please check the permissions and owner of that directory. If executing pip with sudo, you may want sudo’s -H flag."

and it does not install pymysql.

Error thrown while running pip install pymysql inside container is

Installing collected packages: pymysql ERROR: Could not install packages due to an EnvironmentError: [Errno 13] Permission denied: ‘/usr/local/lib/python3.6/site-packages/pymysql’ Consider using the –user option or check the permissions.

Tried pip install pymysql –user also but same error.

2

Answers


  1. To some extent the error message already show the answer:

    sudo -H pip install pymysql
    

    A pretty reson for sudo -H

    When you run sudo your environment is passed along while the effective user switches to root. Your environment includes that your ~/ or home directory (the value of the environment variable HOME) is /home/bijay.

    pip looks for an http cache before downloading packages. Probably for a combination of security, sanity and privacy reasons pip disables the cache so as not to write to a cache directory not owned by the current user. It’s just telling you that it did that.

    As it hints, using sudo -H would set the HOME environment variable before executing the command passed to sudo, using root’s home directory /root as $HOME instead of your user’s. The cache could then be written in /root/.cache/pip/http with no errors.
    As a sidenote, you probably shouldn’t be running pip as root anyway.

    Login or Signup to reply.
  2. If you’re using docker-compose, check out this article: https://preset.io/blog/2020-05-18-install-db-drivers/

    Basically, extra packages can be added by adding them to docker/requirements-local.txt before running docker-compose up.

    Note: requirements-local.txt is installed into the locally built image: https://github.com/apache/incubator-superset/blob/master/Dockerfile-dev#L23

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