17

I'm trying to compile Python file which uses urllib.request, BeautifulSoup, and webbrowser.

$ nuitka python.py
Nuitka:WARNING:python.py:16: Cannot find 'urllib.request' as relative or absolute import.
Nuitka:WARNING:python.py:17: Cannot find 'bs4' as relative or absolute import.

$ ./python.exe
Traceback (most recent call last):
  File "python.py", line 16, in <module>
    from urllib.request import urlopen
ImportError: No module named request
JAL
  • 41,701
  • 23
  • 172
  • 300
George J
  • 355
  • 2
  • 14
  • 2
    I don't know what nuitka is, but `no module named request` looks an awful lot like a python2 v. python3 mismatch. – Wayne Werner Jan 19 '16 at 19:41
  • Include the import statements for bs4 and request in your question, and also your file names. – Nick Feb 07 '20 at 14:36

4 Answers4

1

Try to add --recurse-to=urllib to command line during Nuitka execution. See Nuitka help for details.

M. Hebda
  • 11
  • 2
0

You have both python2 and python3 installed in your system check python version usin

$python --version

urllib.request will only be missing if nuitka is using python2 to compile your python3 code. there is no urllib.request in python2.7

same with bs4 ..

there is python2 lurking in your system somewhere and nuitka is using that to compile your python3 code

to ensure python3 is used

$/path to python3/python -m nuitka program.py

or where python 3.7 is aliased as python3

$python3 -m nuitka program.py
geekay
  • 340
  • 1
  • 5
-2

You can use Nuitka to compile Python programs to standalone executables,then redistribute them without the Python runtime

  • 1
    This does not provide an answer to the question. Once you have sufficient [reputation](https://stackoverflow.com/help/whats-reputation) you will be able to [comment on any post](https://stackoverflow.com/help/privileges/comment); instead, [provide answers that don't require clarification from the asker](https://meta.stackexchange.com/questions/214173/why-do-i-need-50-reputation-to-comment-what-can-i-do-instead). - [From Review](/review/late-answers/33503722) – Chris Warrick Dec 28 '22 at 10:51
-2

You can use different compiler like pycharm or the VScode to compile your python code.