Problem with imports

Sébastien Bigaret <[email protected]> Fri, 13 May 2016 17:59:23 +0200
Newsgroups gmane.comp.lang.jython.user
Organization Télécom Bretagne
Message-ID <[email protected]>
    Hi all,

I have currently a problem with imports I do not understand.
This is what happens (Jython 2.7.0, java 1.8.0u66, on debian 8):

----8< ---- 8< ----
./jython.sh
Jython 2.7.0 (default:9987c746f838, Apr 29 2015, 02:25:11) 
[Java HotSpot(TM) 64-Bit Server VM (Oracle Corporation)] on java1.8.0_66
Type "help", "copyright", "credits" or "license" for more information.
>>> import sys; sys.path
['', '/path/to/XMCDA-java.jar', '/home/bigaret/lang/python/Lib', '/home/bigaret/lang/python/jython-standalone-2.7.0.jar/Lib', '__classpath__', '__pyclasspath__/']
>>> import org.xmcda.parsers.xml   # this one fails here....
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
ImportError: No module named xmcda
>>> from org.xmcda.parsers.xml.xmcda_3_0 import XMCDAParser
>>> import org.xmcda.parsers.xml   # ...but now it succeeds
>>> org.xmcda.parsers.xml
<java package org.xmcda.parsers.xml 0x2>
>>> sys.path
['', '/path/to/XMCDA-java.jar', '/home/bigaret/lang/python/Lib', '/home/bigaret/lang/python/jython-standalone-2.7.0.jar/Lib', '__classpath__', '__pyclasspath__/']
----8< ---- 8< ----


Note that the first import fails, while the last (which is the same statement) succeeds --and sys.path was untouched, there is just an import between the two identical imports)

Does someone has any hint why I get such a strange behaviour, or can point me to the right documentation to read? I could unfortunately not find any hint on such peculiarities when searching in jython's doc or on the web in general.

Thanks in advance,

__ Sébastien.


NB: The jython.sh is a simple bash script:

----8< ---- 8< ----
#! /bin/bash
JAVA=/usr/local/java8/bin/java
JYTHON_STANDALONE_JAR=/home/bigaret/lang/python/jython-standalone-2.7.0.jar
XMCDA_LIB="/path/to/XMCDA-java.jar"

export JYTHONPATH="${XMCDA_LIB}"

"${JAVA}" -cp "${JYTHON_STANDALONE_JAR}" org.python.util.jython
----8< ---- 8< ----

(and I have the same behaviour when adding XMCDA_LIB to the java '-cp' argument.

-- 
Sébastien Bigaret
Institut Mines-Télécom - Télécom Bretagne (Département LUSSI)
CNRS - UMR 6285 Lab-STICC (Pôle CID - Équipe DECIDE)
Technopôle Brest-Iroise - CS 83818 - 29238 Brest Cedex 3 - France
Tél. +33 (0)2 29 00 14 22

------------------------------------------------------------------------------
Mobile security can be enabling, not merely restricting. Employees who
bring their own devices (BYOD) to work are irked by the imposition of MDM
restrictions. Mobile Device Manager Plus allows you to control only the
apps on BYO-devices by containerizing them, leaving personal data untouched!
https://ad.doubleclick.net/ddm/clk/304595813;131938128;j

_______________________________________________
Jython-users mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/jython-users
signature.asc (application/pgp-signature, 836 B)
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.12 (GNU/Linux)

iQIcBAEBAgAGBQJXNfnbAAoJEHU8D0nY/H+mFN0QAIjGKurT1oyOBqIB3Rlr2nCc
Ss2ykeewjEYwJY/dB4Zz+F6zl/Y0W5WNYLHmCbp9MvC9TfTB2lGIuj7RmQVIgwdV
oIJ6oP+BPkNQutzbzRpcm4Uv3g3UoGFTt25F6p3i5xX3ugbtpGfNTSEt7IU84YPu
iZSvQp2MS7gfHQiWCzrdnjbnEXjdHjWsIb0F4W5y6P3opx1nhA+bb3pjOsEs7+ii
7i0Utf2VGBZvOdpufppSm+mWzv8Hh9UgLj4fHv3kNnHpg1BDowYWwDC4QDbuMMC2
VIb4NesJEB8BpRyQGASMsZZ/mFIUClfWB2Gok4TJ1pGiKJr/CEQiSlr5TfBBvVXY
o53NjHPD/5UQApacC/NAcQCEDEgmOG3KE/xx00sRAVANolcA9mFZBK7Hd18wSqf2
CuPj4/99JNZh+tYoVwP14TfzdSIz8IpJJdNeFXgNDKGX7SSgOt0sht0ttSWInqx+
G1yZu9VQT07fOxwe+rOLyEPuoumA7YJZIYxVYD11WyuELRJo7ELtnE29CcNMV2yN
f3tk+ghHXRkyhq4EMbltjDGjufdMHkxXNZpUkmSwNbfg5tcAs4ICtdtFVNLonRCe
3ON27a39fThGW0BHbjaRPln860fkM+wMyMgKTfI9Z4IcZfu5gfIWDqbj2PCPH56j
8K7djg6qEylB3cNiJXaS
=Etjj
-----END PGP SIGNATURE-----