![](/img/trans.png)
[英]“ImportError: cannot import name connect” when trying to import Stem
[英]“ImportError: cannot import name…” when trying to run Python script in Docker
我有一个 Python 脚本我想在 Docker 容器中运行,但它停止并出现错误:
File "main.py", line 1, in <module>
from pushover import init, Client
ImportError: cannot import name 'init' from 'pushover' (/usr/local/lib/python3.8/dist-packages/pushover/__init__.py)
在 PyCharm 中,脚本运行良好。 Dockerfile 看起来像这样:
RUN apt-get update -y && apt-get install git python3 python3-pip -y; \
git clone https://(path to my script) ; \
pip3 install pushover
WORKDIR "/FNotify/"
CMD python3 main.py;
我在脚本中的导入如下所示:
from pushover import init, Client
import os
from time import sleep
您对错误的 package和正确的 package 感到困惑,所以接下来应该安装的是:
pip3 install python-pushover
结果:
# python3
Python 3.6.7 (default, Oct 22 2018, 11:32:17)
[GCC 8.2.0] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> from pushover import init
>>>
此外, python-pushover
网页提供了与您相同的示例用法:
from pushover import init, Client
init("<token>")
Client("<user-key>").send_message("Hello!", title="Hello")
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.