[arch-general] python2: Where is imp.py?

Peter Nabbefeld peter.nabbefeld at gmx.de
Mon Dec 31 10:01:16 UTC 2018


Well, it's even more complicated:
I want to use Jython from a maven-based Java project (without installing 
Jython on my Linux laptop). It refuses to run a PythonInterpreter 
because of missing scripts, so I added the path to /usr/lib/python2.7, 
but this doesn't seem to work.

Just today I've found there's another maven-artifact: jython-standalone. 
This does work for inspect, imp etc., but I don't know how to import 
libraries like numpy. However, this is not a Linux problem anymore - 
just didn't know that python 2.7 implements imp as a builtin and thus 
thought there'd be a problem with the installed package ...

Thank You for pointing that out!

Kind regards

Peter



Am 31.12.18 um 00:42 schrieb Eli Schwartz via arch-general:
> On 12/30/18 6:19 PM, Peter Nabbefeld wrote:
>> Am 30.12.18 um 23:06 schrieb Eli Schwartz via arch-general:
>>> On 12/30/18 4:04 PM, Peter Nabbefeld wrote:
>>>> Hello,
>>>>
>>>> I need to use the inspect module with python 2.7, but the imported imp
>>>> module seems to be missing - how can I get that, as there's no
>>>> python2-imp package?
>>> That's categorically impossible as the imp module is a builtin in
>>> python2 and imp.py is a (deprecated!) part of the stdlib in python3.
>>>
>>> You should definitely be able to "import imp". Please explain your
>>> problem further.
>>>
>> I try to use the inspect module with jython, but the import of imp fails.
>>
>> inspect.py exists in /usr/lib/python2.7 (and also in
>> /usr/lib/python3.7), while imp.py exists only in /usr/lib/python3.7
>>
>> If it's a builtin in python2, it seems I have bad luck, though.
> Then this was very important information you should have mentioned in
> the first place. You told us originally you were trying to use python2,
> now you're claiming you're actually using jython.
>
> jython and python2 have nothing to do with each other. They don't use
> the same pythonpath, and jython can be installed without having python2
> installed at all.
>
> jython ships its own independent copies of the standard library,
> byte-compiled into Java .class files instead of cpython .py files, and
> actually does include its own imp.py file which simply imports from
> jython.jar at org/python/modules/_imp.class
>
> I can just as easily import imp on jython as I can on python2 or
> python3. It's part of the stdlib, any python implementation (cpython,
> jython, pypy) is *required* to have it.
>


More information about the arch-general mailing list