我在 docker 中运行 apache superset 0.36,为 redis 和 postgres 使用单独的 docker。尝试连接到在主机上运行的 MySQL 数据源时,出现错误 “错误:superset.views.core:意外错误没有名为‘pymysql’的模块” .
我尝试 bash 来超集容器“sudo docker run -it superset_superset bash”,然后 “点安装 pymysql” 但收到警告 “警告:目录'/home/superset/.cache/pip/http'或其父目录不属于当前用户并且缓存已被禁用。请检查该目录的权限和所有者。如果执行pip sudo,您可能需要 sudo 的 -H 标志。” 它不安装pymysql。
在容器内运行 pip install pymysql 时抛出的错误是“安装收集的包:pymysql 错误:由于 EnvironmentError 无法安装包:[Errno 13] Permission denied:'/usr/local/lib/python3.6/site-packages/pymysql' 考虑使用 --user 选项或检查权限。” 也试过 pip install pymysql --user 但同样的错误。
对此的任何帮助将不胜感激。
最佳答案
在某种程度上,错误消息已经显示了答案:
sudo -H pip install pymysql
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.
关于mysql - 错误 :superset. views.core:意外错误没有名为 'pymysql' 的模块,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/63384876/