0

I am working in NetBeans 7 with Python script using Jython. I am trying to build a NASA WorldWind example.

I have added JARs to the classpath, including the one that contains gov.nasa.worldwind.

The code crashes, saying

  Traceback (most recent call last):
  File "C:\Users\wrightky\Documents\NetBeansProjects\WW\src\ww.py", line 4, in <module>
  import gov.nasa.worldwind as wwj
  ImportError: No module named gov

I have both added the JAR with "gov" to the classpath and even added the JAR to the Python package manually, under which I can see gov.nasa.worldwind.

I could add my code but not sure if it's relevant.

Why would this happen?

Kyle Wright
  • 520
  • 2
  • 9
  • 23

2 Answers2

1

From your question it's not entirely clear whether you're compiling a Java class file or something from Python, but if it is Java you should know that you can't do import X as Y in Java. If you have conflicting class names, you'll just have to always use the fully-qualified class name (ie gov.nasa.wordwind.SomeClass) every time you reference it.

See this question for more details: Change Name of Import in Java, or import two classes with the same name

Community
  • 1
  • 1
StormeHawke
  • 5,987
  • 5
  • 45
  • 73
  • The code is Python, but needs to use Java libraries and WorldWind JARs. I will try your suggestion, though. – Kyle Wright Aug 19 '13 at 16:31
  • Upon removing the 'as Y' and replacing Y with X, I get the same error, that gov, a package within an imported JAR, cannot be found. – Kyle Wright Aug 19 '13 at 16:33
  • 1
    unfortunately I'm a Java guy, lacking much knowledge of python. Hopefully somebody more knowledgeable in the ways of Python will be able to help you out. Sorry my suggestion didn't help. – StormeHawke Aug 19 '13 at 16:36
  • Yes. I wasn't sure what to attribute this error to, Python or Java. Thanks for the suggestion. – Kyle Wright Aug 19 '13 at 16:44
0

I was able to solve this problem in Eclipse, and I am not sure of the analogous solution in NetBeans though it isn't important to me at this point. Simply importing a JAR file is not enough to claim its functionality. It must be added to the Interpreter Libraries.

Window -> Preferences -> PyDev -> Interpreter - Jython -> New Folder (I did New Jar/Zip(s) as well, I assume either would solve the issue) and point to the directory (or JAR).

Kyle Wright
  • 520
  • 2
  • 9
  • 23