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

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.

Related

eclipse pydev debug source lookup

So I have anaconda installed and make a separate environment for all my projects. Normally I just use PYDEV to create a new interpreter pointing to the anaconda enviornment and load the project in eclipse and all is good. After doing the last one though 95% of the time I go to debug I keep getting the error
An internal error occurred during: "Debug Source Lookup".
java.lang.IllegalArgumentException
The other 5% it kind of works as I can follow one script or a function before it starts breaking.
I've tried reloading the project, interpreter and conda enviornment to no luck. All my past projects which use to work are also now giving the same error.
The funny thing is when I'm in the debug perspective though it does seem to be working (I can see the Variables and use the interactive console to test stuff), but anytime I try to step into, over ect I get the error (even though it does seem to be working). So for the image above I can go through the code fine until it tries to jump to the other file which throws the error, but if I step into it I can manually open that file and walk through the function (just each step throws the error) and still interact with the code which is in the position through the console.
Any ideas how to fix?
Well, it may be something specific to this use-case (for instance, if the code for some object is evaluated and the source code is not really available for the debugger this is actually expected).
Can you provide the full stacktrace from the error log? (see: http://www.pydev.org/faq.html#HowdoIReportaBUG for details on how to get it)

Running an OpenCV program with Eclipse

I'm trying to run a simple example of OpenCV on Eclipse [which was perfectly buit and installed before (using CMake and MinGw), even libraries and all includes are in place !].
When building, I'm getting no errors or warning, all seems good, but when I try to run, I get a message as if the project had no Binaries, even if all binaries are there. I even specified the path to the ".exe" (run->run conf-> new launch-> browse ...etc.).
You can notice on the images attached that the project is built and the binaries are generated.
Notice: when I run an example of a (Hellow world) on the console ... it displays the messag without errors.
I read a lot on Internet before posting here, but I found nothing that matches to this case.
Thank you so much,
Error Capture
Build Capture
Regards

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

Overriding acm.program init() method; does Java have to be this hard?

Java problems
I am a student of Java. I managed to write about 15 Java programs so far and get them working on the PC. But I have not yet written a init() method like my latest assignment requires in order to initialize some instance variables. The compiler tells me that my init() method is attempting to override the final init() method in the acm.program. Isn’t that what an init() method is supposed to do? After exhausting all avenues on PC for the last week, I thought maybe it is an Eclipse problem on the PC. All the example code in the Java documentation shows little Mac windows. So I thought I would try moving my code to a Mac running Lion OS 10.7.2.
Switching to MAC environment.
The Mac claims to have Java installed but I think it’s just the run time environment, not a development environment. All I could find for applications is the Java VisualVM, which I assume is the virtual machine so there is no java development software. So… I downloaded Eclipse for Mac from Stanford’s website and got Eclipse IDE for Java Developers Version: Helios Service Release 2 and tried to run a simple program which included an import statement.
The import acm.program.*; statement is giving the compiler a problem: "acm cannot be resolved”. After researching this I think the problem is I have not downloaded the acm.jar archive and added that to my build path. Why this isn’t already done for me, as part of Eclipse I have no clue. I guess everything has to be difficult.
So I downloaded the acm.jar archive and it’s sitting in my download folder. I tried double clicking it and thankfully the mac won’t execute it. I tried dragging it into my source folder in Eclipse and then adding it to the build path. Once in the build path, Eclipse tells me the jar is missing. So I removed it from the build path and instead from inside Eclipse went to Properties/Java Build Path/Libraries/add External JARS… and navigated to my downloads folder where the acm.jar folder is to select the JAR. However, Eclipse seems to be looking for a .jar;.zip file, which there are none because my Mac helpfully already unzipped the folder. So I changed the open window to look for all files (.) and now I see individual .java files that are too numerous to add to the build path individually.
So back to the PC and download the acm.jar zip file and copy it over to the Mac in unzipped form and again add it to the build path as a zip file. This resolved the compiler error and my simple program executed on the Mac!
Next I will try my program with the init() method to see if that now works. Nope. Same problem on the Mac. This init method causes the following error: Multiple markers at this line
overrides acm.program.Program.init
Cannot override the final method from
Program
public void init() {
canvas = new HangmanCanvas();
add(canvas);
}
Does it have to be this hard or am I missing something?
Generally Macs have the whole JDK installed. Eclipse is nice, though.
This "acm" package isn't installed because it's not any kind of standard thing; this is like asking why your refrigerator doesn't come with asparagus already in it.
That last dialog was the right one; you need the original jar file. Try again, right-click and "Save As..." the link to save the file from your browser.
See 3. I find it particularly funny that anybody would use a Windows computer to make up for shortcomings of a Mac; in reality the Mac is infinitely more flexible and more powerful.
If you got a message that complains you're trying to override a final method, then you are indeed trying to do something wrong; final actually means "You're not allowed to override this." Perhaps you didn't fully understand the instructions for the assignment.
It gets better, I promise. Just be sure to use each of these annoyances as a learning experience.
There is no reasons why Java for the Mac would be any better than Java for the PC. The language and tools should work the same ... assuming that you are using the same versions of the language and similar versions of the tools.
Your problem with init is nothing to do with PCs versus Macs. So don't waste your time switching platforms to try to fix it. You need to figure out what the
On the face of is, the compiler / IDE is telling you the truth. Java won't let you override a final method. In fact the whole point of declaring a method to be final is to prevent overloading.
However, this does not make sense. According to the documentation I found here, the acm.program.Program.init() method is designed to be overridden. So why won't it let you?
I suspect that the cause of your problems is that you've downloaded or been given a copy of the JAR file that someone has messed around with. Someone has changes the method to be final (for some reason best kown to themselves), compiled it and put it up for people to download. Google is not always your friend ...
So, what I suggest you do is review all of the handouts and the files that were provided to find either the copy of the JAR that is provided, or the instructions on WHERE to download it from. Then replace the copy of the JAR you are currently using with the recommended one.
Why this isn’t already done for me, as part of Eclipse I have no clue. I guess everything has to be difficult.
How is Eclipse supposed to know what this "acm" stuff is? Which version you require? Where to download it from?

Eclipse for php on Mac OSX 10.5: "Animation Start" error

I am having a terrible time getting Eclipse with php/pdt installed on my older 2006 MacBook running 10.5.8.
I have MAMP installed and running php 5.3.5. That works fine. The zend debugger information shows up correctly in phpinfo() and I have dummy.php in the correct location. 127.0.0.1 is allowed in the config file.
I have eclipse itself installed. I also have tried "Eclipse for php Developers" v3.0.2.
Both installations return errors when I try and run or debug a script. I am trying to use Zend Debugger.
The error is:
"Animation Start has encountered a problem". An Internal error has occurred.
An internal error has occurred.
java.lang.NullPointerException
I have the php executable set as
/Applications/MAMP/bin/php5.3/bin/php (CLI)
Suggestions?
The problem with the "Animation Start has encountered a problem" error dialog doesn't have to do with the php scripts but rather is just an UI quirk/error that is irritating and is likely because of a mis-configured dock:icon property on the eclipse.ini (or whatever eclipse product the zend product uses).
Find the root executable that launches eclipse-based product.
Open up the application executable (.app) package contents
Go to the Contents/MacOS/ folder
Edit the ini file
Make sure that you have this line correctly specificed:
-Xdock:icon=../Resources/<NameofIconFile>.icns
Then restart eclipse/zend
Now you should be able to invoke scripts and not see that invalid error dialog.
You can uncheck "launch in background" in the "common" tab of debug/run configuration.
Ok, I wanted to simply comment on my "success", following gamerson's answer with a slight adaptation... But it seems like I don't have enough "rep" to do that yet, so here goes ;-)
I had this annoying issue for a little while, and also had a second copy of eclipse for java installed on my macbook. It seems like my eclipse pdt did not contain any .icns files (I did a full recursive search of the dir with "find ."... So I thought, I'll copy it from that other eclipse app I have. And I made sure the ini config file (mentioned by gamerson) had the correct path. And voila! No more of that annoying error popup in eclipse, and also the dock where I had a link to the app now has a nice icon (which before was some ugly "generic" icon with pencils and paper, that all makes sense now). Only downside is that I now have two similar dock icons (the PDT one and the Java one lol) but that is a totally minor annoyance. I guess I could "hack" my dock and give it a funky icon while at it ;-)
Thanks internets!