[arch-general] python2: Where is imp.py?
Eli Schwartz
eschwartz at archlinux.org
Sun Dec 30 23:42:32 UTC 2018
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.
--
Eli Schwartz
Bug Wrangler and Trusted User
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 833 bytes
Desc: OpenPGP digital signature
URL: <https://lists.archlinux.org/pipermail/arch-general/attachments/20181230/02606b3a/attachment.asc>
More information about the arch-general
mailing list