views:

1157

answers:

5

I was able to configure NetBeans for 2.6.1 by going to to the Python Platform Manager, creating a new platform, and pointing NetBeans at python.exe where I installed 2.6.1. However, when I follow the exact same steps for 3.0, I get an error in the NetBeans console that says "SyntaxError: invalid syntax".

If it matters, Python is installed in this format:

/Program Files
    /Python
        /2.6
            python.exe and everything else
        /3.0
            python.exe and everything else

I'm wondering if anyone else has experienced this and what they did to correct the problem.

+5  A: 

Yep- it's actually very easy. The scripts in the plugin use 'print' as a keyword which has been changed in Python 3; you just have to convert all 'print' statements in the console.py and platform_ info.py files under the 'python1' folder in your NetBeans installation directory to use parenthesis. For instance, in platform_info.py the first print line says:

print "platform.name="+ "Jython " + version

Change it to:

print("platform.name="+ "Jython " + version)

And do this for all print statements. Then go into the NetBeans and import your Python30 directory into the Python Platform Manager; it will work just fine.

I haven't run into any other issues yet, but there might be some other small syntax issues in the plugin; they should be very easy to fix.

Will this allow me to use Python 2.6 as well as 3.0? I don't want to make any changes that will not let me do 2.6 development as well.
Thomas Owens
+2  A: 

It doesn't let me comment back here so I'll answer your comment in an post.

Yes, it will let you use Python 2.x as well; the 'print' method was both a keyword and function prior to Python 3, so the parenthesis were optional. As on 3 they are required, so this change is backwards compatible.

A: 

There are some issues with debugging, btw- I'll let you all know when I successfully figure out what has to be updated here.

A: 

Thank you Ben Flynn for the solution to integrate python30 with netbeans 6.71

However, this piece of code :

def fib(n):    # write Fibonacci series up to n
     """Print a Fibonacci series up to n."""
     a, b = 0, 1
     while b < n:
         print (b, end=' ')
         a, b = b, a+b

fib(2000)

Which is an example code from a help site, runs with out error from the IDE, but the editor complains:

Internal parser error
"no viable alternative at input'=' "

Which suggests it is parsing against python2.5.1

In case this is a followup question you should not post it as an answer, but as a new question. I'm not sure though, since you don't really ask anything. But it also doesn't seem to answer the question. In the upper right there is a "Ask Question" button that allows you to ask a new question. You can always link back to this question for reference.
sth
A: 

Starting at version 3.0, the print statement has to be written as a function...

your

print (b, end=' ')

becomes

print("end= ", b)