Question: Sublime Text 2: Output Error After I Installed Anaconda
0
gravatar for camachofrancine
3.7 years ago by
United States
camachofrancine90 wrote:

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: 

{
    "path": "/Users/username/anaconda/bin/python",
    "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 • 4.7k views
ADD COMMENTlink modified 3.7 years ago • written 3.7 years ago by camachofrancine90

The "path" variable should not include python, it should just point to the bin directory I think?

/Users/username/anaconda/bin
ADD REPLYlink modified 3.7 years ago • written 3.7 years ago by James Ashmore2.6k

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 REPLYlink written 3.7 years ago by camachofrancine90

According to this stack overflow thread you need to append Python to your current PATH, like so:

"path": "$PATH:/Users/username/anaconda/bin"
ADD REPLYlink modified 3.7 years ago • written 3.7 years ago by James Ashmore2.6k
1
gravatar for camachofrancine
3.7 years ago by
United States
camachofrancine90 wrote:

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 COMMENTlink written 3.7 years ago by camachofrancine90

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 REPLYlink written 3.7 years ago by John12k
1

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. 

ADD REPLYlink modified 3.7 years ago • written 3.7 years ago by camachofrancine90

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 :)

ADD REPLYlink written 3.7 years ago by John12k
Please log in to add an answer.

Help
Access

Use of this site constitutes acceptance of our User Agreement and Privacy Policy.
Powered by Biostar version 2.3.0
Traffic: 1625 users visited in the last hour