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
2
  • 2
    I don't know what nuitka is, but no module named request looks an awful lot like a python2 v. python3 mismatch. Commented Jan 19, 2016 at 19:41
  • Include the import statements for bs4 and request in your question, and also your file names. Commented Feb 7, 2020 at 14:36

4 Answers 4

1

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

Sign up to request clarification or add additional context in comments.

Comments

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

Comments

-2

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

1 Comment

This does not provide an answer to the question. Once you have sufficient reputation you will be able to comment on any post; instead, provide answers that don't require clarification from the asker. - From Review
-2

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

1 Comment

Neither pycharm or vscode are compilers

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.