Sublime Forum

Sublime 2's Default Python issue (OSX Lion)

#1

I have installed several sublime packages via Package Control, but I cannot run every single package due to rfind() error in python from Sublime Console.

Traceback (most recent call last):
  File "./sublime_plugin.py", line 259, in run_
  File "./run_ruby_test.py", line 177, in run
  File "/System/Library/Frameworks/Python.framework/Versions/2.6/lib/python2.6/posixpath.py", line 82, in split
    i = p.rfind('/') + 1
AttributeError: 'NoneType' object has no attribute 'rfind'

Sometimes I got error about ‘no attribute “group”’.

I am pretty sure that Sublime Text 2 preferred Python2.6. It looked for “/System/Library/Frameworks/Python.framework/Versions/2.6/”.

I see a list of python versions:

$ ls /System/Library/Frameworks/Python.framework/Versions/
2.3     2.5     2.6     2.7     Current

I installed Python 2.7.1 from python.org, but Sublime is still using 2.6. I renamed “2.6” folder to “2.6-disabled”, but Sublime 2 crashed for not finding python 2.6. I gave up.

Is there a way that I can fix the ‘rfind’ and ‘group’ issues?

FYI, I am using OSX Lion

0 Likes

#2

It looks like your issue is with run_ruby_test.py (which is not part of the default install of Sublime Text), rather than anything to do with Python versions.

0 Likes

#3

I just downloaded the latest beta of Sublime Text 2 from the sublime text site and I am getting the same error that nayrb describes. I don’t have anything new or added to the default installation. I am a newbie trying to use this for a “learn to program” class I’m taking online. Here’s my error message:

Traceback (most recent call last):
File “./sublime_plugin.py”, line 325, in run_
File “./exec.py”, line 109, in run
File “/System/Library/Frameworks/Python.framework/Versions/2.6/lib/python2.6/posixpath.py”, line 119, in dirname
i = p.rfind(’/’) + 1
AttributeError: ‘NoneType’ object has no attribute ‘rfind’

By the way, I am running Lion on a Mac Book Pro. Is there a fix for this? Did I not set something? Please help if you can. I see the first post was submitted in November 2011, this is now March of 2012. Thanks.

0 Likes

#4

@sstraub: Make sure to save your file before running build. Why you might ask?

Sublime Text ends up at this function (cited in the error you received) while running build:

 def dirname(p):
     """Returns the directory component of a pathname""" 
    i = p.rfind('/') + 1
     head = p:i]
     if head and head != '/'*len(head):
         head = head.rstrip('/')
     return head

rfind from the Python docs:

If your script hasn’t been saved, an empty value is passed into dirname instead of a string, and Python dies when attempting None.rfind("/").

I assume @nayrb’s error results from a similar issue. I wouldn’t ever recommend changing the disabling a system Python… A lot more can crash than just Sublime Text.

0 Likes

#5

I think there must be something wrong with the Sublime Text 2.0 for Mac OS Lion.
The ctagsplugin does not work correctly on my iMac. Every time, when I rebuild the tags after an action of “save all”, ctagsplugin either runs forever (not stopping), or prints error information on Python console terminal as below:

Traceback (most recent call last):
File “./sublime_plugin.py”, line 362, in run_
File “./ctagsplugin.py”, line 597, in run
File “./ctagsplugin.py”, line 196, in find_top_folder
File “/System/Library/Frameworks/Python.framework/Versions/2.6/lib/python2.6/posixpath.py”, line 119, in dirname
i = p.rfind(’/’) + 1
AttributeError: ‘NoneType’ object has no attribute ‘rfind’

This problem is not sovled even after I change the Python version from 2.7 (default for Mac OS 10.7 Lion) to 2.6 by using cmd below:
“defaults write com.apple.versioner.python Version 2.6”

0 Likes

#6

That looks like an error with the plugin. Try opening up an issue on its github page.

0 Likes