ModuleNotFoundError:没有名为“pyrogram”的模块

ModuleNotFoundError:没有名为“pyrogram”的模块

我正在尝试执行 python 脚本,但总是收到错误 - ModuleNotFoundError: No module named 'pyrogram' 。所以我做了 pip3 install Pyrogram 并且 Pyrogram 模块安装成功,但最后我在尝试执行 python 脚本时遇到了同样的错误。我正在使用 linux mint 19.3 如果有帮助的话。下面我发布了整个输出——

xd003@xd003:~/mirror-bot$ python3 generate_string_session.py
Traceback (most recent call last):
  File "generate_string_session.py", line 1, in <module>
    from pyrogram import Client
ModuleNotFoundError: No module named 'pyrogram'
xd003@xd003:~/mirror-bot$ pip3 install pyrogram
Collecting pyrogram
  Using cached https://files.pythonhosted.org/packages/aa/6d/ffe5c490dce53d179ec7d1326190ea2efa7089ed3a7b3a37689899e10a32/Pyrogram-0.16.0-py3-none-any.whl
Collecting pyaes==1.6.1 (from pyrogram)
Collecting pysocks==1.7.0 (from pyrogram)
  Using cached https://files.pythonhosted.org/packages/cd/18/102cc70347486e75235a29a6543f002cf758042189cb063ec25334993e36/PySocks-1.7.0-py3-none-any.whl
Installing collected packages: pyaes, pysocks, pyrogram
Successfully installed pyaes-1.6.1 pyrogram-0.16.0 pysocks-1.7.0
xd003@xd003:~/mirror-bot$ python3 generate_string_session.py
Traceback (most recent call last):
  File "generate_string_session.py", line 1, in <module>
    from pyrogram import Client
ModuleNotFoundError: No module named 'pyrogram'
xd003@xd003:~/mirror-bot$ 

答案1

您需要解决 pyaes 模块的问题:

  error: invalid command 'bdist_wheel'

  ----------------------------------------
  Failed building wheel for pyaes
  Running setup.py clean for pyaes
Failed to build pyaes

中建议了几种解决方案https://stackoverflow.com/questions/34819221/why-is-python-setup-py-saying-invalid-command-bdist-wheel-on-travis-ci 最有可能的解决方案是:

sudo apt-get install gcc libpq-dev -y
sudo apt-get install python-dev  python-pip -y
sudo apt-get install python3-dev python3-pip python3-venv python3-wheel -y
pip3 install wheel

问题解决后,您需要确保整个安装通过从头开始没有错误

pip3 uninstall pysocks, pyaes, pyrogram
pip3 install pyrogram

相关内容