Build of Sublime Text 2 gives different result than ipython on the command line

Asked

Viewed 449 times

2

I’m trying to migrate to Sublime Text 2 and do everything without leaving the program. Before I ran a script with the following line:

from scipy.stats import beta, bernoulli, gaussian_kde

In the shell within the iPithon the control wheel normally.

If I give the build (cmd+b or Tools -> Build) inside Sublime Text 2 it does not find the scipy.stats and returns the following error:

Import: No module named scipy.Stats

How to solve this?

1 answer

3


Probably Sublime Text is using another Python installation (which has not installed the Scipy library).

To use the correct Python version, you need to modify a configuration in the file Python.sublime-build, which gets into Preferences > Browse Packages » Python. The correct setup depends on your system, your settings, and your personal preferences:

Option 1: Change the Python installation path

Set the path to your Python installation manually inside "cmd":

"cmd": ["C:/caminho/do/python/python.exe", "-u", "$file"],

Option 2: Specify PATH

Copy the contents of your PATH variable to "path":

"path": "C:\\caminho\\do\\python;C:\\caminho\\de\\outra\\coisa",

Option 3: Specify PYTHONPATH

Specify the desired PYTHONPATH path in a dictionary entry "env":

"env": {
    "PYTHONPATH":"C:/caminho/do/python;C:/caminho/do/python/2.7.2/lib/python2.7/site-packages"
},
  • Indeed, it seems that the sublime already comes with a Python instead of fetching the latest version. I am using mac, so I made a modification different from the one suggested by you, but thanks for the answer! First I caught the path in the shell with the command env, then pasted the path into the file python.sublime-build with "path": "caminho do env",.

  • 1

    Ok! I will give an organized response to contemplate all possible solutions. I also use Mac, but since we are minority, I left the answer in Windows default, haha..

Browser other questions tagged

You are not signed in. Login or sign up in order to post.