Sublime Text 2: Output Error After I Installed Anaconda
1
0
Entering edit mode
5.8 years ago
frcamacho ▴ 190

Hi all,

I am trying to use Sublime Text 2 (ST2) editor to run a python script, but am getting errors. Before I installed Anaconda ST2 worked fine, but now I can't build with ST2.

My Python.sublime-build file in ST2 is the following:

{
"cmd": ["python", "-u", "$file"], "file_regex": "^[ ]*File \"(...*?)\", line ([0-9]*)", "selector": "source.python" } However, when I try to build and run my script I get the following error from ST2: [Errno 20] Not a directory [cmd: [u'python', u'-u', u'/Users/username/Desktop/pythonscript.py']] [dir: /Users/username/Desktop] [path: /Users/username/anaconda/bin/python] [Finished] I am thinking that ST2 just needs a path to know which python executable to use, but I am unsure what that path is. I have changed the path to /usr/local/bin, but then I get: Traceback (most recent call last): File "/Users/username/Desktop/pythonscript.py", line 3, in <module> import pandas as pd ImportError: No module named pandas [Finished in 0.2s with exit code 1] Does anyone know why I am getting this error? Thanks in advance! software error • 5.7k views ADD COMMENT 0 Entering edit mode The "path" variable should not include python, it should just point to the bin directory I think? /Users/username/anaconda/bin ADD REPLY 0 Entering edit mode Thanks for the reply, I appreciate the help. Adding the path you suggested I was able to get a result but I got some strange output. sh: sysctl: command not found sh: grep: command not found sh: sw_vers: command not found sh: grep: command not found /Users/username/anaconda/lib/python2.7/site-packages/numexpr/cpuinfo.py:50: UserWarning: [Errno 2] No such file or directory stacklevel=stacklevel+1) /Users/username/anaconda/lib/python2.7/site-packages/numexpr/cpuinfo.py:71: UserWarning: [Errno 2] No such file or directory stacklevel=stacklevel+1): True [Finished in 1.0s] ADD REPLY 0 Entering edit mode According to this stack overflow thread you need to append Python to your current PATH, like so: "path": "$PATH:/Users/username/anaconda/bin"
1
Entering edit mode
5.8 years ago
frcamacho ▴ 190

Figured out my issue, and it was indeed the path that was causing the problem (Thank you James Ashmore for the tip!)

The path I needed to use was

"path": "/Users/username/anaconda/bin:$PATH" ADD COMMENT 0 Entering edit mode Weird that flipping the$PATH: to the other end of the string made a difference - out of curiosity, do you know if Anaconda works if you don't have the path line at all, and just have:

"cmd": ["/Users/username/anaconda/bin/python", "-u", "$file"] ADD REPLY 1 Entering edit mode For Python in order to find the modules I am using in my script along with sublime, I need to have the path in which all the modules are saved under. In my case, the modules are saved where anaconda is installed. So first, you place the path then$PATH which means go to where anaconda's modules are located( in my case I downloaded Pandas via anaconda) then, execute Python that is on your system. If the $PATH is first then we get an IMPORT ERROR because the module, Pandas is located not on the system but where the anaconda is installed. Just having the following: "cmd": ["/Users/username/anaconda/bin/python", "-u", "$file"]

it doesn't work when I tried it.

0
Entering edit mode

Ah, ok, shame - I would have thought that anaconda's python somehow knows about where all its modules are kept, but I guess it has to be in the path too. Thank you for clearing that up in my head :)