Sublime Forum

ST3 cannot find packages installed with macports

#1

Is there way to make ST3 aware of python packages installed with macports…

Seems to have to do with the PATH variable and (maybe?) macports installing software as a Framework??

From the Terminal -> python3 “import numpy” works fine.
but from ST3, ~‘no package numpy found’

Any help???

0 Likes

#2

The Python environments are 100% separate. Sublime Text has its own version of Python with its own include paths. This is to prevent system changes from breaking Sublime Text.

You can compile and add (Python) packages to the Python used by Sublime Text, but not via your system Python. You effectively need to place them into a folder and then add them to the sys.path in the Sublime Text python environment. Adding such a folder to sys.path is usually performed by a Sublime Text package, which leads into…

If you want to get more advanced, and allow such Python packages to be available to Sublime Text packages, you can look into Package Control dependencies. There are some differences in that .py files should not be placed into the root of a Sublime Text package folder, otherwise Sublime Text will try to load it as a Sublime Text package. If you look at existing Package Control dependencies, you can see how issues like this are handled.

To go down this path, you should probably expect to do a bit of digging, as there aren’t really tutorials since this is sort of an advanced use-case.

2 Likes

#3

Will,

Thanks for your reply!

I understand about half of what you are saying…

Guess my fundamental question is: how can I add numpy, scipy, etc to the python that ST3 uses.

I need their functionality.

Drek

0 Likes

#4

That is indeed what Package Control dependencies would be used for, but I’d suggest you re-evaluate whether you actually need to embed numpy into ST’s Python environment because it won’t be a walk in the park.

What’s usually a good idea in cases like these is to run a script with the system’s Python distribution and request the user to install numpy/scipy manually. subprocess will play a huge role in that.

Other than that, we might be able to give better recommendations depending on what you actually want to do.

1 Like

#5

Thanks for your reply. Based on these two replies, I think I will just use ST3 as a fancy editor and run my programs from the Terminal. Make sense?

0 Likes

#6

Yes, definitely.

0 Likes