Subject: bug#46569: closed (Re: bug#46569: python can't find internal pip modules in environment from manifest)

From: [email-masked] (GNU bug Tracking System)
Date: Thu, 18 Feb 2021 21:19:02 +0000

Your bug report

#46569: python can't find internal pip modules in environment from manifest

which was filed against the guix package, has been closed.

The explanation is attached below, along with your original report.
If you require more details, please reply to [email-masked].

-- 
46569: http://debbugs.gnu.org/cgi/bugreport.cgi?bug=46569
GNU Bug Tracking System
Contact [email-masked] with problems

Subject: Re: bug#46569: python can't find internal pip modules in environment from manifest
From: Maxim Cournoyer <[email-masked]>
To: Jelle Licht <[email-masked]>
Cc: [email-masked]
Date: Thu, 18 Feb 2021 16:18:47 -0500
List-Id: <debbugs-submit.debbugs.gnu.org>

Hello Jelle,

Jelle Licht <[email-masked]> writes:

> Python can not load all pip-related python modules when loaded from a
> manifest file, yet seems to work fine when loaded 'directly' as part of
> a `guix environment'-invocation.
>
>
> Provided that we have a file in `hi.py':
>
> import pip
> print("halfwaypoint")
> import pip._internal.index.package_finder
> print("I made it!")

The problem seems to be related to the version of pip used.  The one
bundled with our Python on master is:

$ guix environment --pure --ad-hoc python -- pip3 --version
pip 19.2.3 from
/gnu/store/pw65c67dmzr2m9wbkj5mskhm6ljk6xal-profile/lib/python3.8/site-packages/pip
(python 3.8)

and

$ guix environment --pure --ad-hoc python -- python3 -c 'import pip._internal.index.package_finder'
Traceback (most recent call last):
  File "<string>", line 1, in <module>
ModuleNotFoundError: No module named
'pip._internal.index.package_finder'; 'pip._internal.index' is not a
package

but

$ guix environment --pure --ad-hoc python python-pip -- pip3 --version
pip 20.2.4 from
/gnu/store/d75bwzbla5ybhs0mdw80qy94mawnhhsw-python-pip-20.2.4/lib/python3.8/site-packages/pip
(python 3.8)

and

$ guix environment --pure --ad-hoc python python-pip -- python3 -c 'import pip._internal.index.package_finder'
$ echo $?
0

HTH!

Closing.

Maxim

Subject: python can't find internal pip modules in environment from manifest
From: Jelle Licht <[email-masked]>
To: [email-masked]
Date: Tue, 16 Feb 2021 21:58:20 +0100
List-Id: <debbugs-submit.debbugs.gnu.org>

Python can not load all pip-related python modules when loaded from a
manifest file, yet seems to work fine when loaded 'directly' as part of
a `guix environment'-invocation.

Provided that we have a file in `hi.py':
--8<---------------cut here---------------start------------->8---
import pip
print("halfwaypoint")
import pip._internal.index.package_finder
print("I made it!")
--8<---------------cut here---------------end--------------->8---

and a `manifest.scm' with:

--8<---------------cut here---------------start------------->8---
(use-modules (gnu) (guix packages)
	     (gnu packages python)
	     (gnu packages python-xyz))

(packages->manifest (list python python-pip))
--8<---------------cut here---------------end--------------->8---

I can get the expected output by running:
`guix environment --pure --ad-hoc python python-pip -- python3 hi.py' =>
> halfwaypoint
> I made it!

Yet, when I run the following:
`guix environment --pure -m manifest.scm -- python3 hi.py' =>

--8<---------------cut here---------------start------------->8---
halfwaypoint
Traceback (most recent call last):
  File "hi.py", line 4, in <module>
    import pip._internal.index.package_finder
  File "/gnu/store/4m5vhlq61qnj36rq60l83xcmgj3mx92j-profile/lib/python3.8/site-packages/pip/_internal/__init__.py", line 40, in <module>
    from pip._internal.cli.autocompletion import autocomplete
  File "/gnu/store/4m5vhlq61qnj36rq60l83xcmgj3mx92j-profile/lib/python3.8/site-packages/pip/_internal/cli/autocompletion.py", line 8, in <module>
    from pip._internal.cli.main_parser import create_main_parser
  File "/gnu/store/4m5vhlq61qnj36rq60l83xcmgj3mx92j-profile/lib/python3.8/site-packages/pip/_internal/cli/main_parser.py", line 11, in <module>
    from pip._internal.commands import (
  File "/gnu/store/4m5vhlq61qnj36rq60l83xcmgj3mx92j-profile/lib/python3.8/site-packages/pip/_internal/commands/__init__.py", line 6, in <module>
    from pip._internal.commands.completion import CompletionCommand
  File "/gnu/store/4m5vhlq61qnj36rq60l83xcmgj3mx92j-profile/lib/python3.8/site-packages/pip/_internal/commands/completion.py", line 6, in <module>
    from pip._internal.cli.base_command import Command
  File "/gnu/store/4m5vhlq61qnj36rq60l83xcmgj3mx92j-profile/lib/python3.8/site-packages/pip/_internal/cli/base_command.py", line 26, in <module>
    from pip._internal.index import PackageFinder
ImportError: cannot import name 'PackageFinder' from 'pip._internal.index' (/gnu/store/4m5vhlq61qnj36rq60l83xcmgj3mx92j-profile/lib/python3.8/site-packages/pip/_internal/index/__init__.py)
--8<---------------cut here---------------end--------------->8---

Why is there a difference in the first place? Shouldn't both approaches work?

- Jelle