Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Python > Difficulty with "inconsistent use of tabs and spaces in indentation"in file called <string>

Reply
Thread Tools

Difficulty with "inconsistent use of tabs and spaces in indentation"in file called <string>

 
 
ibloom
Guest
Posts: n/a
 
      02-11-2008
I've been trying for a couple days to build a program using pyObjC on
a mac, I'm stuck on this error:

<string>: inconsistent use of tabs and spaces in indentation
Traceback (most recent call last):
File "setup.py", line 59, in ?
setup(**setup_options)
File "/Library/Frameworks/Python.framework/Versions/2.4//lib/
python2.4/distutils/core.py", line 149, in setup
dist.run_commands()
File "/Library/Frameworks/Python.framework/Versions/2.4//lib/
python2.4/distutils/dist.py", line 946, in run_commands
self.run_command(cmd)
File "/Library/Frameworks/Python.framework/Versions/2.4//lib/
python2.4/distutils/dist.py", line 966, in run_command
cmd_obj.run()
File "/Library/Frameworks/Python.framework/Versions/2.4/lib/
python2.4/site-packages/py2app/py2app/build_app.py", line 342, in run
self.initialize_plist()
File "/Library/Frameworks/Python.framework/Versions/2.4/lib/
python2.4/site-packages/py2app/py2app/build_app.py", line 415, in
initialize_plist
plist = self.get_default_plist()
File "/Library/Frameworks/Python.framework/Versions/2.4/lib/
python2.4/site-packages/py2app/py2app/build_app.py", line 294, in
get_default_plist
version = find_version(target.script)
File "/Library/Frameworks/Python.framework/Versions/2.4/lib/
python2.4/site-packages/py2app/py2app/util.py", line 13, in
find_version
ast = compiler.parseFile(fn)
File "/Library/Frameworks/Python.framework/Versions/2.4//lib/
python2.4/compiler/transformer.py", line 48, in parseFile
return parse(src)
File "/Library/Frameworks/Python.framework/Versions/2.4//lib/
python2.4/compiler/transformer.py", line 52, in parse
return Transformer().parsesuite(buf)
File "/Library/Frameworks/Python.framework/Versions/2.4//lib/
python2.4/compiler/transformer.py", line 129, in parsesuite
return self.transform(parser.suite(text))
File "<string>", line 628
else:
^
SyntaxError: invalid syntax

I don't even know which file has the indentation problem.

Any thoughts.
Ian Bloom
 
Reply With Quote
 
 
 
 
Gabriel Genellina
Guest
Posts: n/a
 
      02-11-2008
En Mon, 11 Feb 2008 13:34:17 -0200, ibloom <(E-Mail Removed)> escribi´┐Ż:

> I've been trying for a couple days to build a program using pyObjC on
> a mac, I'm stuck on this error:
>
> <string>: inconsistent use of tabs and spaces in indentation
> Traceback (most recent call last):
> File "setup.py", line 59, in ?
> setup(**setup_options)
> File "/Library/Frameworks/Python.framework/Versions/2.4//lib/
> python2.4/distutils/core.py", line 149, in setup
> dist.run_commands()
> File "/Library/Frameworks/Python.framework/Versions/2.4//lib/
> python2.4/distutils/dist.py", line 946, in run_commands
> self.run_command(cmd)
> File "/Library/Frameworks/Python.framework/Versions/2.4//lib/
> python2.4/distutils/dist.py", line 966, in run_command
> cmd_obj.run()
> File "/Library/Frameworks/Python.framework/Versions/2.4/lib/
> python2.4/site-packages/py2app/py2app/build_app.py", line 342, in run
> self.initialize_plist()
> File "/Library/Frameworks/Python.framework/Versions/2.4/lib/
> python2.4/site-packages/py2app/py2app/build_app.py", line 415, in
> initialize_plist
> plist = self.get_default_plist()
> File "/Library/Frameworks/Python.framework/Versions/2.4/lib/
> python2.4/site-packages/py2app/py2app/build_app.py", line 294, in
> get_default_plist
> version = find_version(target.script)
> File "/Library/Frameworks/Python.framework/Versions/2.4/lib/
> python2.4/site-packages/py2app/py2app/util.py", line 13, in
> find_version
> ast = compiler.parseFile(fn)


Put a print statement just above that line, to see which file triggers the
error.

--
Gabriel Genellina

 
Reply With Quote
 
 
 
 
mensanator@aol.com
Guest
Posts: n/a
 
      02-11-2008
On Feb 11, 9:34*am, ibloom <(E-Mail Removed)> wrote:
> I've been trying for a couple days to build a program using pyObjC on
> a mac, I'm stuck on this error:
>
> <string>: inconsistent use of tabs and spaces in indentation
> Traceback (most recent call last):
> * File "setup.py", line 59, in ?
> * * setup(**setup_options)
> * File "/Library/Frameworks/Python.framework/Versions/2.4//lib/
> python2.4/distutils/core.py", line 149, in setup
> * * dist.run_commands()
> * File "/Library/Frameworks/Python.framework/Versions/2.4//lib/
> python2.4/distutils/dist.py", line 946, in run_commands
> * * self.run_command(cmd)
> * File "/Library/Frameworks/Python.framework/Versions/2.4//lib/
> python2.4/distutils/dist.py", line 966, in run_command
> * * cmd_obj.run()
> * File "/Library/Frameworks/Python.framework/Versions/2.4/lib/
> python2.4/site-packages/py2app/py2app/build_app.py", line 342, in run
> * * self.initialize_plist()
> * File "/Library/Frameworks/Python.framework/Versions/2.4/lib/
> python2.4/site-packages/py2app/py2app/build_app.py", line 415, in
> initialize_plist
> * * plist = self.get_default_plist()
> * File "/Library/Frameworks/Python.framework/Versions/2.4/lib/
> python2.4/site-packages/py2app/py2app/build_app.py", line 294, in
> get_default_plist
> * * version = find_version(target.script)
> * File "/Library/Frameworks/Python.framework/Versions/2.4/lib/
> python2.4/site-packages/py2app/py2app/util.py", line 13, in
> find_version
> * * ast = compiler.parseFile(fn)
> * File "/Library/Frameworks/Python.framework/Versions/2.4//lib/
> python2.4/compiler/transformer.py", line 48, in parseFile
> * * return parse(src)
> * File "/Library/Frameworks/Python.framework/Versions/2.4//lib/
> python2.4/compiler/transformer.py", line 52, in parse
> * * return Transformer().parsesuite(buf)
> * File "/Library/Frameworks/Python.framework/Versions/2.4//lib/
> python2.4/compiler/transformer.py", line 129, in parsesuite
> * * return self.transform(parser.suite(text))
> * File "<string>", line 628
> * * else:
> * * ^
> SyntaxError: invalid syntax
>
> I don't even know which file has the indentation problem.


Maybe none of them do. An indentation error isn't necessarily
due to indentation. I just saw one last Saturday, but I don't
remember what caused it other than it wasn't indentation.
Something was open that wasn't closed properly, such as
matching () or [] or ''. Unfortunately, I can't reproduce it.
Examine the code carefully in the sections before the actual
reported error. You may be seeing a symptom rather than the cause.

>
> Any thoughts.
> Ian Bloom


 
Reply With Quote
 
ibloom
Guest
Posts: n/a
 
      02-11-2008
My main problem is, I don't know where to find the file:
File "<string>", line 628

As in I don't know what code it is refering to by <string> ??
It isn't code that I wrote, its something from python or pyObjC

Ian Bloom
 
Reply With Quote
 
Steve Holden
Guest
Posts: n/a
 
      02-12-2008
ibloom wrote:
> My main problem is, I don't know where to find the file:
> File "<string>", line 628
>
> As in I don't know what code it is refering to by <string> ??
> It isn't code that I wrote, its something from python or pyObjC
>

You'll typically see that in code that's being executed from a
dynamically created string in the code, which is going to make it *very*
difficult to debug.

>>> exec "1/0"

Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "<string>", line 1, in <module>
ZeroDivisionError: integer division or modulo by zero
>>> eval('1/0')

Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "<string>", line 1, in <module>
ZeroDivisionError: integer division or modulo by zero
>>>


regards
Steve
--
Steve Holden +1 571 484 6266 +1 800 494 3119
Holden Web LLC http://www.holdenweb.com/

 
Reply With Quote
 
Gabriel Genellina
Guest
Posts: n/a
 
      02-12-2008
En Mon, 11 Feb 2008 21:57:00 -0200, ibloom <(E-Mail Removed)> escribiˇ:

> My main problem is, I don't know where to find the file:
> File "<string>", line 628
>
> As in I don't know what code it is refering to by <string> ??
> It isn't code that I wrote, its something from python or pyObjC


Mmm, didn't you get my previous post? The call is inside the py2app
package. Quoting myself:

>> <string>: inconsistent use of tabs and spaces in indentation
>> Traceback (most recent call last):
>> File "/Library/Frameworks/Python.framework/Versions/2.4/lib/
>> python2.4/site-packages/py2app/py2app/util.py", line 13, in
>> find_version
>> ast = compiler.parseFile(fn)

>
> Put a print statement just above that line, to see which file triggers
> the
> error.


In case it wasn't clear, modify the file
/Library/Frameworks/Python.framework/Versions/2.4/lib/python2.4/site-packages/py2app/py2app/util.py,
around line 13, in the find_version function, adding this print statement:

print 'about to compile', fn
ast = compiler.parseFile(fn)

The last line printed (in case there are many) should be the offending
filename.

Of course you don't have to keep the modified library, this is just to
detect which file triggers the error. You should report this to the py2app
developers as well.

--
Gabriel Genellina

 
Reply With Quote
 
ibloom
Guest
Posts: n/a
 
      02-12-2008
On Feb 11, 9:10*pm, "Gabriel Genellina" <(E-Mail Removed)>
wrote:
> En Mon, 11 Feb 2008 21:57:00 -0200, ibloom <(E-Mail Removed)> escribiˇ:
>
> > My main problem is, I don't know where to find the file:
> > * File "<string>", line 628

>
> > As in I don't know what code it is refering to by <string> ??
> > It isn't code that I wrote, its something from python or pyObjC

>
> Mmm, didn't you get my previous post? The call is inside the py2app *
> package. Quoting myself:
>
> >> <string>: inconsistent use of tabs and spaces in indentation
> >> Traceback (most recent call last):
> >> * File "/Library/Frameworks/Python.framework/Versions/2.4/lib/
> >> python2.4/site-packages/py2app/py2app/util.py", line 13, in
> >> find_version
> >> * * ast = compiler.parseFile(fn)

>
> > Put a print statement just above that line, to see which file triggers *
> > the
> > error.

>
> In case it wasn't clear, modify the file *
> /Library/Frameworks/Python.framework/Versions/2.4/lib/python2.4/site-packag es/py2app/py2app/util.py, *
> around line 13, in the find_version function, adding this print statement:
>
> * * *print 'about to compile', fn
> * * *ast = compiler.parseFile(fn)
>
> The last line printed (in case there are many) should be the offending *
> filename.
>
> Of course you don't have to keep the modified library, this is just to *
> detect which file triggers the error. You should report this to the py2app *
> developers as well.
>
> --
> Gabriel Genellina


You are right, I didn't understand. I'll try it. Thank you.

Ian Bloom
 
Reply With Quote
 
ibloom
Guest
Posts: n/a
 
      02-13-2008
On Feb 11, 9:10*pm, "Gabriel Genellina" <(E-Mail Removed)>
wrote:
> En Mon, 11 Feb 2008 21:57:00 -0200, ibloom <(E-Mail Removed)> escribiˇ:
>
> > My main problem is, I don't know where to find the file:
> > * File "<string>", line 628

>
> > As in I don't know what code it is refering to by <string> ??
> > It isn't code that I wrote, its something from python or pyObjC

>
> Mmm, didn't you get my previous post? The call is inside the py2app *
> package. Quoting myself:
>
> >> <string>: inconsistent use of tabs and spaces in indentation
> >> Traceback (most recent call last):
> >> * File "/Library/Frameworks/Python.framework/Versions/2.4/lib/
> >> python2.4/site-packages/py2app/py2app/util.py", line 13, in
> >> find_version
> >> * * ast = compiler.parseFile(fn)

>
> > Put a print statement just above that line, to see which file triggers *
> > the
> > error.

>
> In case it wasn't clear, modify the file *
> /Library/Frameworks/Python.framework/Versions/2.4/lib/python2.4/site-packag es/py2app/py2app/util.py, *
> around line 13, in the find_version function, adding this print statement:
>
> * * *print 'about to compile', fn
> * * *ast = compiler.parseFile(fn)
>
> The last line printed (in case there are many) should be the offending *
> filename.
>
> Of course you don't have to keep the modified library, this is just to *
> detect which file triggers the error. You should report this to the py2app *
> developers as well.
>
> --
> Gabriel Genellina


Gabriel, your the master.
Of course I didn't understand that py2app was trying to compile my own
python source code and when I switched to Xcode as my new editor, I
started mixing in tabs. So <string> was in fact my code. All I had to
do was change my preferences in Xcode, to generate spaces instead of
tabs, remove all of the offending tabs and voila. You've ended days of
frustrations. Thank you.

Ian Bloom
 
Reply With Quote
 
greg
Guest
Posts: n/a
 
      02-13-2008
ibloom wrote:
> Of course I didn't understand that py2app was trying to compile my own
> python source code and when I switched to Xcode as my new editor, I
> started mixing in tabs. So <string> was in fact my code.


Seems like py2app could be a bit friendlier about reporting
syntax errors in the code it's trying to compile!

--
Greg
 
Reply With Quote
 
Gabriel Genellina
Guest
Posts: n/a
 
      02-13-2008
En Tue, 12 Feb 2008 22:57:01 -0200, ibloom <(E-Mail Removed)> escribi´┐Ż:

> On Feb 11, 9:10┬*pm, "Gabriel Genellina" <(E-Mail Removed)>
> wrote:
>>
>> >> <string>: inconsistent use of tabs and spaces in indentation
>> >> Traceback (most recent call last):
>> >> ┬* File "/Library/Frameworks/Python.framework/Versions/2.4/lib/
>> >> python2.4/site-packages/py2app/py2app/util.py", line 13, in
>> >> find_version
>> >> ┬* ┬* ast = compiler.parseFile(fn)

>>
>> > Put a print statement just above that line, to see which file >

>> triggers the error.
>>

>
> Gabriel, your the master.
> Of course I didn't understand that py2app was trying to compile my own
> python source code and when I switched to Xcode as my new editor, I
> started mixing in tabs. So <string> was in fact my code. All I had to
> do was change my preferences in Xcode, to generate spaces instead of
> tabs, remove all of the offending tabs and voila. You've ended days of
> frustrations. Thank you.


Glad to be of any help. Note that all the clues were on the traceback.
When people here insist that all error reports should come with the
complete stack trace, it isn't because they want to be annoying, but
because it's really useful...

--
Gabriel Genellina

 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Is there a way to configure IDLE to use spaces instead of tabs for indenting? Alex Python 12 10-17-2012 03:34 PM
Tabs -vs- Spaces: Tabs should have won. rantingrick Python 95 07-18-2011 11:07 PM
CSV::Writer... Using tabs instead of commas (or creating excel file using tabs to seperate data) John Kopanas Ruby 2 01-29-2007 06:26 PM
List text files showing LFs and expanded tabs (was: Colorize expanded tabs) qwweeeit Python 2 12-14-2005 10:07 AM
How to use split on spaces AND tabs? nospam Perl 2 07-03-2004 09:23 PM



Advertisments