I am trying to use Sublime text IDE for my Python projects. But after ensuring the build system, I am not able to run any program there. I am getting ModuleNotFoundError
as soon as I import modules like NumPy
, pandas
.
Here is some useful information:
> import sys
> print (sys.executable)
/usr/local/bin/python3
The information on pip and Python are following
> which pip
/Users/harish/opt/anaconda3/bin/pip
> which python
/Users/harish/opt/anaconda3/bin/python
I have been using pip to install all the python modules.
I have searched extensively internet, I find no solution. I am using MacBook Pro, macOS Catalonia. (my MPB is an old fart and Apple does not find it worthy to run BigSur)
As you can see from the outputs of sys.executable
(run within Sublime) and which python
(run in the shell), you are not using the same Python binary in both places. To set up Sublime to use the correct one where you installed your packages with pip
, you'll need to create a new build system.
In Sublime, select Tools → Build System → New Build System…
and change its contents to the following:
{
"cmd": [
"/Users/harish/opt/anaconda3/bin/python", "-u", "$file"
],
"working_dir": "$file_path",
"file_regex": "^[ ]*File \"(...*?)\", line ([0-9]*)",
"selector": "source.python"
}
Hit Save, which will automagically open up your Packages/User
folder, and save it there as Python_Anaconda.sublime-build
or something like that. Just don't name it Python.sublime-build
, as a build system with that name already exists.
Now, select Tools → Build System → Python_Anaconda
(or whatever you named it), and you should be able to run programs with the modules you installed previously.