0

I am on Ubuntu 17.04 LTS, and the default Sublime Text 3 build system fails to import modules that are only for Python 3. For example:

>>> import urllib.request
ImportError: No module named request

Whereas I can successfully import other modules. What can I do?

Thanks in advance.

1 Answer 1

1

There is in your home directory a file

~/.config/sublime-text-3/Packages/Python/Python.sublime-build 

which content points to the python executable which should be used for building/running the script.

The content of this file looks like:

{
    "cmd": ["/usr/local/bin/python3", "-u", "$file"],
    "file_regex": "^[ ]*File \"(...*?)\", line ([0-9]*)",
    "selector": "source.python"
}

You can adapt it to your needs specifying the Python3 executable instead of Python2 one.

If you also want your Sublime REPL to run Python3 instead of Python2 change in the

~/.config/sublime-text-3/Packages/SublimeREPL/config/Python/Main.sublime-menu 

file the lines:

"cmd": ["python", "-i", "-u"] 

to

"cmd": ["python3", "-i", "-u"]

(see also here for some more about it).

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

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.