PyDev code analysis not working properly - eclipse

I'm having a problem with PyDev and Eclipse. This first happened with some old EasyEclipse version I had. I thought it was just because the EasyEclipse install was old, but it's now also happening with Eclipse 4.2.1 and PyDev 2.7.1. I'm running Python 2.7.3.
The problem is the type-time code analysis seems to be faulty or running the wrong Python version. It thinks this line has a syntax error:
x = 1 if some_boolean else 2
It's expecting a newline instead of the if-keyword. When running the module it works as expected.
This is very annoying as this one error seems to mess up further code analysis that would actually be useful. I'm not sure if it has something to do with the problem, but this site instructed me to try running the interpreterInfo.py, so here is the XML dump it generated.
Any thoughts?

Go to Project -> Properties, click on PyDev - Interpreter/Grammar, and then choose 2.7 in the "Grammar Version" drop-down.

Related

Net Beans "Must set src.dir" error when generating jforms

I have developed a problem, I cannot resolve.
I am running Net Bean 8.2 Build: 201609300101.
I am running it on a Windows 7 platform.
Yesterday Net Bean worked fine and would generate the jforms for me. Last night something happened and I can no-longer build, compile and run jforms classes.
I can generate and run simple Java programs. I wrote a simple program that just prints "Hello" and that worked.
When I generate a jform, everything looks good in the IDE but it will not build or run.
I get the following error:
c:users\Admin\Documents\Netbeans\KensPanel\nbproject\build-impl.xml:899 Must set src.dir.
None of the NetBeans examples work either and they did yesterday.
In reviewing the posts on the NetBeans forum concerning the problem, I found several that suggested looking in "nbproject directory for a project.properties file. in the file there should be a "build.dir = build" statement. It is there.
I have completely deleted the project and rebuilt the program and that did not work.
I uninstalled the NetBeans program, the JDK and the JRE programs and reinstalled them (JDK & JRE first) and that did not fix the problem.
I put a simple print statement "(System.out.println("Hello");" in the "Public Static void Main(String[] args)" function at the bottom of the KensPanel.java file and the program will compile and print out "Hello" but will not bring up the GUI.
I get the feeling the problem is somehow related to the "ANT" process but anything having anything to do with that is way over my head.
As I stated earlier, the program worked yesterday afternoon. Last night, the IDE decided that it did not want to play any more and I have not been able to find the problem. I am at a loss.
I am real new to the program and for that matter, Java in general. I really need help.
Ken
I think I found my own answer. At least, I got around the problem.
In the New Java application screen, I had left the "create Main Class" box checked. I found in the NetBeans tutorial, the tutorial stated that I needed to "un-check" the box. When I did that, at least my application works. I haven't tried the examples yet.
Moving on to the next learning task.
Ken

Pydev 3.0 + Eclipse + Google App Engine Debugging not working

I've been having problems getting debugging working with this setup for the past year. Supposedly, this is fixed in the latest versions, but I just can't seem to get it to work.
I'm using Mac OSX 10.8.5, Eclipse Keplar, PyDev 3.0.0, and Google App Engine 1.8.8.
I set up a run configuration to point to dev_appserver.py, running my project. That works fine. My python version is 2.7.3, and everything works in normal mode. When I try to run in debug mode, however, the app runs, the output specifically states:
pydev debugger: starting
pydev debugger: google app engine integration enabled
But after 20 seconds, the python process terminates with this error message:
'Launching New_configuration' has encountered a problem.
Timed out after 20.0 seconds while waiting for python script to connect.
Accept timed out
Execution works during those 20 seconds, because I can hit URLs connected to my app and see an effect. Breakpoints do not work, though. Is there something I need to do to get python to 'connect'?
Also - I should note that switching back to using 'old_dev_appserver.py' fixes this problem - debugging works fine when I do this. But, this is not really a solution, because I need to use the latest socket additions in the newer releases.
Thanks for any advice.
temporary solution:
edit the pydev_app_engine_debug_startup.py file:
eclipse/plugins/org.python.pydev_${VERSION}/pysrc/pydev_app_engine_debug_startup.py
change the line that reads:
if ':' not in config.version_id:
to:
if ':' not in config.version_id or config.version_id.startswith('default:'):
Looks like this is fixed in 1.9.0. I also had to make sure to update PyDev to the latest (3.3.3 at the time of this writing).
One more thing to add, and this one really tripped me up (on MacOS) -
In Eclipse, under Run -> Run Configurations, set the Main Module to point to this location:
/usr/local/google_appengine/dev_appserver.py
NOT the symlink:
/usr/local/bin/dev_appserver.py
Well, finally I found the answer. It is a Google's bug.
It has been reported and acknowledged.
see Debug is not working with PyDev again 1.8.8!
Update: Until the bug is fixed I am using PyCharm. The pro version has 30 days trial and works with GAE. It works like, well, a charm. I may even consider switching to it from Elicpse/PyDev
But I am used to JetBrains tools with Android Studio recnetly, and WebStorm and Resharper in the past, so I know to find my way around their IDEs. Your milage may and will vary.
Since the question, a new GAE has been released 1.8.9
Running GAE 1.8.9 with PyDev3.3.3 on Windows8.
This timeout issue still occurred.
When I entered the temporary workaround changes to pydev_app_engine_debug_startup described in the earlier answer, then the browser could not connect to the app.
However, on backing out this change, not only did the 'Launching New_configuration' not appear, but the breakpoints worked.
More info on the Python Tool Support for the App Engine Development Server is here
https://docs.google.com/document/d/1CCSaRiIWCLgbD3OwmuKsRoHHDfBffbROWyVWWL0ZXN4/edit

PyDev: "Unresolved import nltk" When running, pydev imports it

I want to get rid of this error message and I want to have the benefits of auto completion and suggestions. PyDev obviously does find nltk, because when running it from inside the IDE it works. Not only from console.
Surely someone needs to know why I got this "unresolved import" error message but on the other way when clicking on "run" it works perfectly well.
#TheGT seems to be on the correct path, though I found the instructions a little confusing. My solution:
Project->Properties->PYDEV-PYTHONPATH->External Libraries
Add source folder (button)
/Library/Python/2.7/site-packages/nltk-2-0/4-py2.7.egg
Obviously, your path, version, etc... could be different.
Here's what seems odd.
There's a button to add zip/jar/egg and that doesn't want to work correctly with the nltk...directory...egg. The nltk egg behaves like a directory in the chooser (i.e. continues to drill down rather than return).
On the other hand, the source folder button does allow you to choose a folder... so I chose the egg and that seems to work.
It seems like the nltk egg is not configured correctly for OSX. And, depending on how it is accessed, it can behave like a folder or a final destination.
NOTE: Adding the nltk egg into the external libraries path of your project makes the error go away. But adding the egg into preferences>PyDev>Interpreter does not appear to resolve the problem (on it's own).
I faced the exact same error when I was trying to use nltk in my project. I did 2 things to resolve the unresolved error to go away.
I added the setupctools**.egg file (the file that is used to install nltk in mac/*nix systems) as an external library
[Project->Properties->PYDEV-PYTHONPATH->External Libraries]
I am using Eclipse Indigo, and Python 2.6.1 on my mac btw.
I restarted the eclipse
Bam! - the error goes away.
Although, the error is not there anymore, I would like to know why Eclipse was behaving this way. The strange thing to note was that when I tried to run the program, the program did run successfully, even though eclipse marked "import nltk" as unresolved import.

Getting CUSP working in Eclipse

I have just installed the latest unofficial version of Cusp to go along with this tutorial on Cusp. I do exactly as it says, verbatim, and when I save my main.lisp file, I see an error on the (in-package :new-lisp1) line which says
Package NEW-LISP1 not loaded
Right click on corresponding .asd file and select
Load Package
I right-click new-lisp1.asd, select "Load Package," the red error goes away, I try compiling again, and tada--it's back!
Also, another (related?) problem is that down in the REPL, I keep seeing that I am disconnected from SBCL, and I keep trying to reconnect. Basically, the window looks like these lines repeated over and over:
Reconnecting...done.
"You are running SBCL 1.0.8.48 via Cusp 0.9.375"
Disconnected
What can I do to fix these problems? (If it is any help, I'm using Eclipse on Mac OS X)
EDIT: and I would also like to note that simply selecting "Load Package" on new-lisp1.asd generates two more "Disconnected" messages immediately...
Okay, so I'm still not sure what caused the problem, but I reinstalled Eclipse fresh and then manually added the older, official release of Cusp to Eclipse. Everything is working fine.
In addition, I tried installing the newer Cusp on Eclipse on the Leopard machines at school, and it works fine. So perhaps it is a problem with Snow Leopard or the Lion beta that I am currently using.

Netbeans compile error, why does it mean?

I finished a Netbeans project a few months ago, it was successfully done, finished. But the strange thing is today I happen to look into it and recompiled it, haven't changed anything, but got the following error, I vaguely remember I encountered similar situations before, just recompile and it will be fine, but not this time, I recompiled a few times, same error, restarted the PC, and recompiled again, same error :
build-impl.xml:501: copylibs doesn't support the "indexMetaInf" attribute
I never touched this file and have no idea why it worked fine, but failed this time, what's wrong and what's the fix ?
It seems that the problem is in version of Ant and new Ant attribute indexMetaInf.
I have the same problem and think it'll be worth to explain how I've got it.
How to obtain the problem:
I use NetBeans 6.8.
Recently I installed NetBeans 7.0. Just for acquaintance with new features.
I accepted to use old NB6.8 configuration, when NB7.0 asked me on the first launch.
That was mistake!
So. I started NB7.0 and my good old NB6.8 projects were there, in the projects list.
The problem is that NB7.0 not only imported my old projects in its projects list; but also
changed build-impl.xml of those projects.
And when I opened my projects in NB6.8 and tryed to compile them, there was that error with "indexMetaInf".
The essence of the problem:
In NB6.8 the Ant 1.7.1 is used, by default. And it seems that attribute "indexMetaInf" is only supported by
latest versions of Ant (maybe starting with 1.8.x). That new version of Ant was installed with NB7.0 and is used by NB7.0 only.
NB6.8 doesn't see it.
How to fix the problem:
I updated build-impl.xml file from subversion and it fixed the problem.
In my previous version of build-impl.xml there was no indexMetaInf.
Had the same problem, fixed it by copying the file org-netbeans-modules-java-j2seproject-copylibstask.jar from [netbeans]\java\ant\extra into the directory myProject\lib\CopyLibs
Strange thing happened again, this time good. I had a backup DVD, from a few weeks ago, I copied the project back, now it's compiling fine again, seems to me the project somehow got corrupted, I did a C: drive defragmentation last week, could it somehow moved some files around and messed up a bit ? Anyhow, not a problem now.
What platform are you using? I've had some odd errors like that on Unix due to trying to compile the project from the command line and having a older version of ant in my path.