0

I am trying to convert a program to an exe using pyinstaller. The program performs a hardware assessment of a user's computer to include running an internet speed test utilizing speedtest-cli. The program runs fine until I compile it at which point I receive the following error:

Traceback (most recent call last):   File "speedtest.py", line 156, in <module> ModuleNotFoundError: No module named '__builtin__'

During handling of the above exception, another exception occurred:

Traceback (most recent call last):   File "hw-assesment-tool.py", line 9, in <module>   File "<frozen importlib._bootstrap>", line 1007, in
_find_and_load   File "<frozen importlib._bootstrap>", line 986, in _find_and_load_unlocked   File "<frozen importlib._bootstrap>", line 680, in _load_unlocked   File "PyInstaller\loader\pyimod03_importers.py", line 546, in exec_module   File "speedtest.py", line 179, in <module>   File "speedtest.py", line 166, in __init__ AttributeError: 'NullWriter' object has no attribute 'fileno'

I have tried upgrading and re-installing speedtest-cli and it has not corrected the issue.

P.S. Here is a screenshot of the error:

Compiled Python EXE error originating in Speedtest-cli

Russ C
  • 5
  • 2

3 Answers3

1

First you need to go to C:\Users\user\AppData\Local\Programs\Python\Python38\Lib\site-packages. Then find the speedtest.py and open it with Notepad or any other Text Editor.

Now you need to edit these lines of code

Line 156: to

import builtins

Line 158 : to

import builtins

Line 199: to

del builtins

To confirm, you can find for __builtin__ and replace it with builtins

0

__builtin__ was changed to builtins in Python 3. I pulled the speedtest-cli code from the repo and edited out the Python2 functionality and it worked fine.

Russ C
  • 5
  • 2
0

I met same issue before, you need to modify the spec file: hiddenimports=['speedtest'], and build exe via spec file(type command: pyinstaller -F main.spec), It's work!

Ervin
  • 1