Sublime Forum

I have a Python module that I imported correctly, that works in IDLE, but not Sublime. Any fixes?

#1

Here are my settings. For many different modules Python tells me that the module can’t be found, even though it works perfectly well in IDLE!

{
“path”: “/Library/Frameworks/Python.framework/Versions/3.5/bin/$PATH”,
“sys.path.append”: “$PATH:/Library/Frameworks/Python.framework/Versions/3.5/lib”,
“sys.path.append”: “$PATH:/Library/Frameworks/Python.framework/Versions/3.5/lib/python3.5/site-packages”,
“cmd”: [“python”, “-u”, “$file”],
“file_regex”: “^[ ]File "(…?)”, line ([0-9]*)",
“selector”: “source.python”,
“word_wrap”: true,
“env”: {
“PYTHONPATH”: “/Library/Frameworks/Python.framework/Versions/3.5/bin” }
}

0 Likes

#2

Try this:

{
"cmd": ["python", "-u", "$file"],
"file_regex": "^[ ]File \"(...?)\", line ([0-9]*)",
"selector": "source.python",
"word_wrap": true, 
"working_dir": "/Library/Frameworks/Python.framework/Versions/3.5/bin"
}
0 Likes

#3

Hi,

I’m having trouble importing 3rd party Python modules into Sublime. I’m pretty sure this has to do with the path?

Here are the settings that I’m using for my Python.Sublime file.

{
    "path": "/Library/Frameworks/Python.framework/Versions/3.5/bin/$PATH",
    	"sys.path.append": "$PATH:/Library/Frameworks/Python.framework/Versions/3.5/lib",
    	"sys.path.append": "$PATH:/Library/Frameworks/Python.framework/Versions/3.5/lib/python3.5/site-packages",
    "cmd": ["python", "-u", "$file"],
    "file_regex": "^[ ]*File \"(...*?)\", line ([0-9]*)",
    "selector": "source.python",
    "word_wrap": true, 
    "env": { "PYTHONPATH": "/Library/Frameworks/Python.framework/Versions/3.5/bin" }

}

One thing that might explain the error is that when I run print(sys.version) Sublime is using 2.7.6. But I’ve already pointed Sublime to 3.5!

0 Likes

#4

On OS X, python is version 2.7. You’ll need to indicate you want a different version:

"cmd": ["python3.5", "-u", "$file"]
0 Likes