Python in NetBeans IDE 7.4

Let's set up NetBeans IDE 7.4 to use Python.

Go to Tools | Plugins and the Plugin Manager opens. In the Settings tab of the Plugin Manager, add a new update center with this URL:

http://deadlock.netbeans.org/hudson/job/nbms-and-javadoc/lastStableBuild/artifact/nbbuild/nbms/updates.xml.gz

Then go to the "Available Plugins" tab of the Plugin Manager and you'll find Python:

After installing the Python plugin, go to the New Project wizard and create your new Python project or import an existing Python project:

Then have fun with Python:

There's lots of features for Python, including debugging and code coverage.

If you don't expect it to be 100% perfect, you'll be 80% satisfied.

Comments:

Nice. But it will be difficult for NB as Idea has free python plugin now. If only this was one year earlier ... I know people who got stuck with NB 6.x just because Python support was removed.

Posted by bubbles.way on December 21, 2013 at 02:06 PM PST #

Great!...

Posted by guest on December 21, 2013 at 06:19 PM PST #

Hello Geertjan,

Thanks for the post. I downloaded the netbeans about 1 month ago, and I was disappointed when I see that it doesn't support python. As I remember Netbeans had python support on previous releases. Why did Oracle drop support? How old is that plugin you downloaded from deadlock repository? The name "Deadlock" doesn't sound promising for active projects :)

Posted by guest on December 21, 2013 at 11:06 PM PST #

Python support has never been removed, it's always been available. It's stable, no more work needs to be done to it, hence that's why it's not being actively developed. It does what you need it to do, so download it and use it.

Posted by Geertjan on December 22, 2013 at 12:29 AM PST #

"it's stable, no more work needs to be done to it"

Sorry, can't agree. Even simplest things do not work. Autocomplete or go to declaration for example. Without it, IDE is nothing more than a text editor. Rename local var throws exceptions and so on.

class Child:
def mybar(self):
print "bar1"

class Parent:
def __init__(self):
child = Child()
child.mybar()# autocomplete, go to declaration???

if __name__ == "__main__":
p = Parent()

Posted by guest on December 22, 2013 at 05:17 AM PST #

From the screenshots above you can see that autocomplete works. And, yes, it's not perfect. Still, it's hard to say it's nothing more than a text editor when it has a debugger and code coverage, to name just two things, isn't it?

Posted by Geertjan on December 22, 2013 at 09:25 PM PST #

child.mybar()

for method mybar() autocomplete does not work, as well as go to declaration. Without it, it is not really an IDE.

The sad thing is, it did work in netbeans 6.7 if I remember correctly

Posted by guest on December 23, 2013 at 12:20 AM PST #

Somehow having problems getting into my blog at the moment, plus several comments got deleted. Will take a look at this problem, but refuse to accept that without code completion something can't be called an IDE.

Posted by Geertjan on December 23, 2013 at 12:26 AM PST #

"guest", can you drop me an e-mail at geertjan.wielenga@oracle.com? Communication easier via e-mail.

Posted by Geertjan on December 23, 2013 at 12:28 AM PST #

This is great but I think that Python in IDE's (any IDE I know that supports Python) starts from an incorrect assumption.
I mean, when you do Python, you write a script in one file and, when it tends to grow too big, you split off classes to separate files. And when they seem to be usefull in other scripts, they go to separate modules.
I, for one, never start with a 'project' in mind. I just have a big pile of scripts in some directory to do my 'dirty', tinyish work for which I do not want to start a full blown jave or c++ project.
I can imagine that people who write full blown (gui) applications in Python will see it differently. But, for my 'dirty' Python work, it is just overkill.

Posted by guest on December 23, 2013 at 01:14 AM PST #

Sorry - but python support in netbeans proofs, that the saying "The moment you stop working on a software, you've got a bug" is true. It rots - in this case I opened a python file, marked a sequence, pressed some keys and got an exception. I would have expected the marked sequence to be replaced. FAIL.

So while it's nice, that there is potential python support, please don't repeatetly tell people, that python support is in netbeans ...

Posted by guest on December 25, 2013 at 02:35 PM PST #

Really, steps, please. Don't know what "marked a sequence" means. Steps, so I can reproduce it.

Posted by Geertjan on December 25, 2013 at 03:08 PM PST #

0. Create sample file:

#! /usr/bin/python
# -*- coding: utf8 -*-
config = {}

1. Open sample file (outside of a project!)
2. Double click on config to mark the sequence of characters
3. Begin typing

I would have expected that in step 3 the marked sequence is deleted and replaced by the first character I typed in that step.

But I get:

java.lang.StringIndexOutOfBoundsException: String index out of range: 0
at java.lang.String.charAt(String.java:658)
at org.netbeans.modules.gsf.GsfEditorKitFactory$GsfEditorKit$GsfDefaultKeyTypedAction.replaceSelection(GsfEditorKitFactory.java:299)
at org.netbeans.editor.BaseKit$DefaultKeyTypedAction$2.run(BaseKit.java:1140)
at org.netbeans.editor.GuardedDocument.runAtomicAsUser(GuardedDocument.java:351)
at org.netbeans.editor.BaseKit$DefaultKeyTypedAction.actionPerformed(BaseKit.java:1131)
at org.netbeans.editor.ext.ExtKit$ExtDefaultKeyTypedAction.actionPerformed(ExtKit.java:1024)
at org.netbeans.modules.gsf.GsfEditorKitFactory$GsfEditorKit$GsfDefaultKeyTypedAction.actionPerformed(GsfEditorKitFactory.java:267)
at org.netbeans.editor.BaseAction.actionPerformed(BaseAction.java:339)

Posted by guest on December 26, 2013 at 07:45 AM PST #

yes, just select a string and start typing. You'll get an IDE exception. And yes, it used to work in previous versions < 7. Python support in Netbeans was "almost there", but I wouldn't recommend it as python IDE right now.

Posted by guest on December 26, 2013 at 01:01 PM PST #

I don't get the error you describe. Anyway, can you drop me an e-mail at geertjan.wielenga@oracle.com? That will help, thank you.

Posted by Geertjan on December 26, 2013 at 02:18 PM PST #

Everyone seems to be complaining, I just want to thank you and everyone who worked on it for the plugin - and the articles

I've been using Netbeans's Python plugin for years, I've tested many other IDE's but none of them was able to replace my Netbeans/Python setup

Yes there are/have been fluctuating minor bugs, but it has always been usable

Anyway thanks

Posted by Kaan Soral on December 30, 2013 at 03:28 PM PST #

@Geertjan: Ok - so I narrowed it down - what I see is most probably bug #209401 - 22 months ago this was filed. I'll add my comment to that bug.

Posted by guest on January 03, 2014 at 11:00 AM PST #

Use the final release, not some random development build, of NetBeans IDE 7.4. That's what I'm doing and not seeing the problem you describe.

Posted by Geertjan on January 03, 2014 at 11:05 AM PST #

As described in the bugreport (maybe this discussion should be there, as with your explanation you could close the bug as NOTABUG...):

This _is_ reproducible:

Create test.py as:

#! /usr/bin/python
# -*- coding: utf8 -*-
# vim: tabstop=8 expandtab shiftwidth=4 softtabstop=4
config = {

}

- Download fresh install of minimum Netbeans (Java SE-Build from https://netbeans.org/downloads/ as ZIP download)
That results in netbeans-7.4-201310111528-javase.zip
- Create empty cache and userdirs (no I won't trash my running configuration just for a test!)
- Unzip Download
- Run the fresh copy of netbeans (netbeans/bin/netbeans --userdir c/h --cachedir c/c)
- Accept licence
- Decline import of config from 7.3
- Install all provided auto updatesar
- Restart netbeans as requested
- Add Deadlock Repository (http://deadlock.netbeans.org/hudson/job/nbms-and-javadoc/lastStableBuild/artifact/nbbuild/nbms/updates.xml.gz)
- Install _only_ the plugins "Python" and "Jython Distribution"
- Restart netbeans as requested
- Open test.py via File -> "Open File"
- select the word config (double clickinig, by keyboard select (arrow keys while holding shift) or mouse marking (click in front of word, hold left mouse button, move mouse behind word, release mouse button)
- Press key "L"
- You will see a red notification bubble in the lower right corner of the netbeans window
- Clicking that opens the notifications area
- A "Unexpected Exception" is shown, with a priority of silent

I can zip the install dir and you can try it yourself!

Just for the record: I'm not in the habit of judging a system from experimental builds.

Oh and the netbeans install I tested with was also downloaded - do you have reason for you accusation? I took the time to dig the bug report, reproduce it, add additional information AND A PATCH - not sure what more you'd expect.

Posted by Matthias on January 04, 2014 at 03:46 AM PST #

The bug is fixed - the patch was pushed into the repository. The nightly builds (see link in Geertjans post) already contain the fix.

Please note, I forgot to increment the version number, so the fix won't be available via autoupdate. To fix this, please:

1. Locate your netbeans userdir: http://wiki.netbeans.org/FaqWhatIsUserdir
2. Change into directory "modules"
3. Delete the following files (=> this removes the problematic file and allows reinstallation of python support):

org-netbeans-modules-gsf.jar
org-netbeans-modules-gsf-api.jar
org-netbeans-modules-gsfpath-api.jar
org-netbeans-modules-python-* (Everything, that starts with org-netbeans-modules-python)

4. Reinstall Python support following the steps in Geertjans post.

Thanks to the netbeans team (in this case Milutin Kristofic) who kindly pushed the change, even though its not his module.

Posted by Matthias on January 08, 2014 at 03:50 AM PST #

Great, well done, and thank you!

Posted by Geertjan on January 08, 2014 at 05:11 AM PST #

Great! I hope, that the Python will be included as standard Language in NetBeans in future! ;)

Posted by guest on January 22, 2014 at 04:20 AM PST #

Can't get auto-complete to work?

Typed

if __n

As in the third screenshot, nothing appears. Fresh install of NB 7.4 with the plugin.

Runs the test ok, just doesn't autocomplete - is there an option required?

Posted by CSpeare on February 04, 2014 at 03:27 AM PST #

Great tutorial! I like Python IDE!

One remark (because it took me hours to figure out what was wrong):
I would recommend to disable the Update Center for Python IDE (http://deadlock.netbeans.org/hudson/job/nbms-and-javadoc/lastStableBuild/artifact/nbbuild/nbms/updates.xml.gz) after the Python IDE is installed. In my first attempt, I did not do that. This caused the "C/C++"-plugin to update from 1.24.2.1 to 1.26.0.1. After this update, NetBeans did not function as it should: the "Tools" > "Plugins" and "Tools" > "Options" popup windows from the menu did not work anymore... and some other things did not work anymore... in short, it makes NetBeans unusable...

Posted by Jochen on February 06, 2014 at 01:34 AM PST #

Is there a Python Shell for this plugin or some equivalent?

Posted by guest on February 07, 2014 at 07:53 AM PST #

Is there a place to contribute to this plugin? It would be great to include Python 3 support or, at least, update the python console to 2.7.x

Posted by Camilo on February 18, 2014 at 06:20 PM PST #

Awesome, thanks.

Posted by Sid on February 20, 2014 at 07:32 PM PST #

thank you, it's really useful

Posted by guest on March 06, 2014 at 08:09 AM PST #

Thanks!Thats very nice topic

Posted by guest on March 12, 2014 at 09:26 AM PDT #

Does anyone know why i can't get plugin? Downloading stucks at couple percents.

Mayby someone has same problem?

Posted by guest on March 16, 2014 at 10:08 AM PDT #

Thanks so much!

Posted by guest on March 16, 2014 at 09:19 PM PDT #

This helped me. Thanks alot.

Posted by chandu on March 25, 2014 at 11:59 PM PDT #

I felt very depressed when I tried to install python plugin on netbeans. I don't know why the editor always tell me my java version is less than 1.7.0, actully it is 1.7.0. BTW, my netbeans's version is 7.3.1, not 7.4.

Posted by roberson on April 09, 2014 at 10:11 PM PDT #

Hey.

After i installed the python plugins i cant open the plugin or preferences menu anymore!
The message appears: org.openide.notifydescriptor.isnodefaultclose()Z

Can you help me please!?
greetings oli

Posted by Oli on April 13, 2014 at 09:29 AM PDT #

Post a Comment:
  • HTML Syntax: NOT allowed
About

Geertjan Wielenga (@geertjanw) is a Principal Product Manager in the Oracle Developer Tools group living & working in Amsterdam. He is a Java technology enthusiast, evangelist, trainer, speaker, and writer. He blogs here daily.

The focus of this blog is mostly on NetBeans (a development tool primarily for Java programmers), with an occasional reference to NetBeans, and sometimes diverging to topics relating to NetBeans. And then there are days when NetBeans is mentioned, just for a change.

Search

Archives
« April 2014
SunMonTueWedThuFriSat
  
12
13
14
18
19
20
21
22
23
24
25
26
27
28
29
30
   
       
Today