S
S
sypher2020-08-13 16:48:12
Python
sypher, 2020-08-13 16:48:12

Trouble compiling python + pyrogram, what's wrong?

compiling a python file with pyinstaller, working with Pyrogram. The file seems to be going, but when it starts it gives an error.

Traceback (most recent call last):
  File "main.py", line 6, in <module>
  File "<frozen importlib._bootstrap>", line 991, in _find_and_load
  File "<frozen importlib._bootstrap>", line 975, in _find_and_load_unlocked
  File "<frozen importlib._bootstrap>", line 671, in _load_unlocked
  File "c:\users\mark\appdata\local\programs\python\python38-32\lib\site-packages\PyInstaller\loader\pyimod03_importers.py", line 493, in exec_module
    exec(bytecode, module.__dict__)
  File "pyrogram\__init__.py", line 23, in <module>
  File "<frozen importlib._bootstrap>", line 991, in _find_and_load
  File "<frozen importlib._bootstrap>", line 975, in _find_and_load_unlocked
  File "<frozen importlib._bootstrap>", line 671, in _load_unlocked
  File "c:\users\mark\appdata\local\programs\python\python38-32\lib\site-packages\PyInstaller\loader\pyimod03_importers.py", line 493, in exec_module
    exec(bytecode, module.__dict__)
  File "pyrogram\client\__init__.py", line 19, in <module>
  File "<frozen importlib._bootstrap>", line 991, in _find_and_load
  File "<frozen importlib._bootstrap>", line 975, in _find_and_load_unlocked
  File "<frozen importlib._bootstrap>", line 671, in _load_unlocked
  File "c:\users\mark\appdata\local\programs\python\python38-32\lib\site-packages\PyInstaller\loader\pyimod03_importers.py", line 493, in exec_module
    exec(bytecode, module.__dict__)
  File "pyrogram\client\client.py", line 40, in <module>
  File "<frozen importlib._bootstrap>", line 991, in _find_and_load
  File "<frozen importlib._bootstrap>", line 975, in _find_and_load_unlocked
  File "<frozen importlib._bootstrap>", line 671, in _load_unlocked
  File "c:\users\mark\appdata\local\programs\python\python38-32\lib\site-packages\PyInstaller\loader\pyimod03_importers.py", line 493, in exec_module
    exec(bytecode, module.__dict__)
  File "pyrogram\client\methods\__init__.py", line 19, in <module>
  File "<frozen importlib._bootstrap>", line 991, in _find_and_load
  File "<frozen importlib._bootstrap>", line 975, in _find_and_load_unlocked
  File "<frozen importlib._bootstrap>", line 671, in _load_unlocked
  File "c:\users\mark\appdata\local\programs\python\python38-32\lib\site-packages\PyInstaller\loader\pyimod03_importers.py", line 493, in exec_module
    exec(bytecode, module.__dict__)
  File "pyrogram\client\methods\bots\__init__.py", line 19, in <module>
  File "<frozen importlib._bootstrap>", line 991, in _find_and_load
  File "<frozen importlib._bootstrap>", line 975, in _find_and_load_unlocked
  File "<frozen importlib._bootstrap>", line 671, in _load_unlocked
  File "c:\users\mark\appdata\local\programs\python\python38-32\lib\site-packages\PyInstaller\loader\pyimod03_importers.py", line 493, in exec_module
    exec(bytecode, module.__dict__)
  File "pyrogram\client\methods\bots\answer_callback_query.py", line 20, in <module>
  File "<frozen importlib._bootstrap>", line 991, in _find_and_load
  File "<frozen importlib._bootstrap>", line 975, in _find_and_load_unlocked
  File "<frozen importlib._bootstrap>", line 671, in _load_unlocked
  File "c:\users\mark\appdata\local\programs\python\python38-32\lib\site-packages\PyInstaller\loader\pyimod03_importers.py", line 493, in exec_module
    exec(bytecode, module.__dict__)
  File "pyrogram\client\ext\__init__.py", line 19, in <module>
  File "<frozen importlib._bootstrap>", line 991, in _find_and_load
  File "<frozen importlib._bootstrap>", line 975, in _find_and_load_unlocked
  File "<frozen importlib._bootstrap>", line 671, in _load_unlocked
  File "c:\users\mark\appdata\local\programs\python\python38-32\lib\site-packages\PyInstaller\loader\pyimod03_importers.py", line 493, in exec_module
    exec(bytecode, module.__dict__)
  File "pyrogram\client\ext\base_client.py", line 32, in <module>
  File "pyrogram\client\ext\base_client.py", line 80, in BaseClient
FileNotFoundError: [Errno 2] No such file or directory: 'C:\\Users\\Mark\\AppData\\Local\\Temp\\_MEI117242\\pyrogram\\client\\ext/mime.types'
[15012] Failed to execute script main

Answer the question

In order to leave comments, you need to log in

2 answer(s)
M
Misha Tarasov, 2020-08-14
@Miha_Tarasov

It says that there is no such file or directory

P
petrlastovsky, 2020-11-27
@petrlastovsky

There is a solution. It may not be relevant anymore, but it might be useful to someone.
First you need to go to the folder with pyrogram in the file scaffold.py We find the folder with pyrogram
with the following code.

import pyrogram
print(pyrogram.__file__)

Specifically, this file and line 65 were written in my error.
Looked like this.
with open(f"{os.path.dirname(__file__)}/mime.types", "r", encoding="UTF-8") as f:

It became so.
with open(f"{os.getcwd()}/mime.types", "r", encoding="UTF-8") as f:

Now the mime.types file will be opened from the project folder. That is, this file must be copied to the project.
After that, you can use pyinstaller and everything will work.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question