Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

ImportError: pip is not installed #2649

Closed
1 task done
vhdirk opened this issue Feb 23, 2024 · 4 comments
Closed
1 task done

ImportError: pip is not installed #2649

vhdirk opened this issue Feb 23, 2024 · 4 comments

Comments

@vhdirk
Copy link

vhdirk commented Feb 23, 2024

  • I have searched the issue tracker and believe that this is not a duplicate.

Make sure you run commands with -v flag before pasting the output.

Steps to reproduce

Initialize a new PDM project using defaults, then add bitstream as dependency

pdm init -v

pdm add -v bitstream

Actual behavior

Initing the project works just fine

pdm init -v

Creating a pyproject.toml for PDM...
Please enter the Python interpreter to use
0. /usr/bin/python (3.11)
1. /usr/bin/python3.12 (3.12)
2. /usr/bin/python3.11 (3.11)
3. /usr/bin/python2.7 (2.7)
Please select (0): 
Would you like to create a virtualenv with /usr/bin/python? [y/n] (y): 
Run command: ['/home/dirk/.local/share/pdm/venv/bin/python', '-m', 'virtualenv', '/home/dirk/devel/pdmtest/.venv', '-p', '/usr/bin/python', '--prompt=pdmtest-3.11', '--no-pip', 
'--no-setuptools', '--no-wheel']
created virtual environment CPython3.11.8.final.0-64 in 31ms
  creator CPython3Posix(dest=/home/dirk/devel/pdmtest/.venv, clear=False, no_vcs_ignore=False, global=False)
  activators BashActivator,CShellActivator,FishActivator,NushellActivator,PowerShellActivator,PythonActivator
Virtualenv is created successfully at /home/dirk/devel/pdmtest/.venv
Project name (pdmtest): 
Project version (0.1.0): 
Do you want to build this project for distribution(such as wheel)?
If yes, it will be installed by default when running `pdm install`. [y/n] (n): 
License(SPDX name) (MIT): 
Author name (Dirk Van Haerenborgh): 
Author email (vhdirk@gmail.com): 
Python requires('*' to allow any) (==3.11.*): 
Project is initialized successfully

Adding the bitstream dependency yields the error

pdm add -v bitstream

Adding packages to default dependencies: bitstream
STATUS: Resolving dependencies
pdm.termui: ======== Start resolving requirements ========
pdm.termui:   bitstream
pdm.termui:   python>=3.11,<3.12
pdm.termui:   Adding requirement bitstream
pdm.termui:   Adding requirement python>=3.11,<3.12
pdm.termui: ======== Starting round 0 ========
STATUS: Resolving: new pin python>=3.11,<3.12
pdm.termui: Pinning: python None
pdm.termui: ======== Ending round 0 ========
pdm.termui: ======== Starting round 1 ========
STATUS: Resolving: new pin bitstream 3.0.1
pdm.termui: Pinning: bitstream 3.0.1
pdm.termui: ======== Ending round 1 ========
pdm.termui: ======== Starting round 2 ========
pdm.termui: ======== Resolution Result ========
pdm.termui: Stable pins:
pdm.termui:      python None
pdm.termui:   bitstream 3.0.1
STATUS: Fetching hashes for resolved packages...
pdm.termui: Fetching hashes for bitstream@3.0.1
🔒 Lock successful
Changes are written to pyproject.toml.
STATUS: Resolving packages from lockfile...
Synchronizing working set with resolved packages: 1 to add, 0 to update, 0 to remove

unearth.preparer: Using cached <Link https://files.pythonhosted.org/packages/85/bc/60cc42dbc7d2ab0ff6caefd1a28c322f8c769261c48f1e67fd727c01e5fc/bitstream-3.0.1.tar.gz (from https://pypi.org/simple/bitstream/)>
pdm.termui: Preparing environment(Isolated mode) for PEP 517 build...
pdm.termui: Saving wheel to cache: <Link https://files.pythonhosted.org/packages/85/bc/60cc42dbc7d2ab0ff6caefd1a28c322f8c769261c48f1e67fd727c01e5fc/bitstream-3.0.1.tar.gz (from https://pypi.org/simple/bitstream/)>
pdm.termui: Running PEP 517 backend to build a wheel for <Link https://files.pythonhosted.org/packages/85/bc/60cc42dbc7d2ab0ff6caefd1a28c322f8c769261c48f1e67fd727c01e5fc/bitstream-3.0.1.tar.gz (from https://pypi.org/simple/bitstream/)>
pdm.termui: ======== Start resolving requirements ========
pdm.termui:   setuptools>=40.8.0
pdm.termui:   wheel
pdm.termui:   python>=3.11.8,<3.11.9
pdm.termui:   Adding requirement setuptools>=40.8.0
pdm.termui:   Adding requirement wheel
pdm.termui:   Adding requirement python>=3.11.8,<3.11.9
pdm.termui: ======== Starting round 0 ========
pdm.termui: Pinning: python None
pdm.termui: ======== Ending round 0 ========
pdm.termui: ======== Starting round 1 ========
pdm.termui: Pinning: setuptools 69.1.1
pdm.termui: ======== Ending round 1 ========
pdm.termui: ======== Starting round 2 ========
pdm.termui: Pinning: wheel 0.42.0
pdm.termui: ======== Ending round 2 ========
pdm.termui: ======== Starting round 3 ========
pdm.termui: ======== Resolution Result ========
pdm.termui: Stable pins:
pdm.termui:       python None
pdm.termui:   setuptools 69.1.1
pdm.termui:        wheel 0.42.0
pdm.termui: Installing setuptools@69.1.1...
unearth.preparer: Using cached <Link https://files.pythonhosted.org/packages/c0/7a/3da654f49c95d0cc6e9549a855b5818e66a917e852ec608e77550c8dc08b/setuptools-69.1.1-py3-none-any.whl (from https://pypi.org/simple/setuptools/)>
pdm.termui: Installing wheel@0.42.0...
unearth.preparer: Using cached <Link https://files.pythonhosted.org/packages/c7/c3/55076fc728723ef927521abaa1955213d094933dc36d4a2008d5101e1af5/wheel-0.42.0-py3-none-any.whl (from https://pypi.org/simple/wheel/)>
pdm.termui: Synchronization complete.
pdm.termui: Traceback (most recent call last):
pdm.termui:   File "<string>", line 16, in <module>
pdm.termui: ModuleNotFoundError: No module named 'pip'
pdm.termui: 
pdm.termui: During handling of the above exception, another exception occurred:
pdm.termui: 
pdm.termui: Traceback (most recent call last):
pdm.termui:   File "/home/dirk/.local/share/pdm/venv/lib/python3.11/site-packages/pyproject_hooks/_in_process/_in_process.py", line 353, in <module>
pdm.termui:     main()
pdm.termui:   File "/home/dirk/.local/share/pdm/venv/lib/python3.11/site-packages/pyproject_hooks/_in_process/_in_process.py", line 335, in main
pdm.termui:     json_out['return_val'] = hook(**hook_input['kwargs'])
pdm.termui:                              ^^^^^^^^^^^^^^^^^^^^^^^^^^^^
pdm.termui:   File "/home/dirk/.local/share/pdm/venv/lib/python3.11/site-packages/pyproject_hooks/_in_process/_in_process.py", line 118, in get_requires_for_build_wheel
pdm.termui:     return hook(config_settings)
pdm.termui:            ^^^^^^^^^^^^^^^^^^^^^
pdm.termui:   File "/tmp/pdm-build-env-47m8wddi-shared/lib/python3.11/site-packages/setuptools/build_meta.py", line 325, in get_requires_for_build_wheel
pdm.termui:     return self._get_build_requires(config_settings, requirements=['wheel'])
pdm.termui:            ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
pdm.termui:   File "/tmp/pdm-build-env-47m8wddi-shared/lib/python3.11/site-packages/setuptools/build_meta.py", line 295, in _get_build_requires
pdm.termui:     self.run_setup()
pdm.termui:   File "/tmp/pdm-build-env-47m8wddi-shared/lib/python3.11/site-packages/setuptools/build_meta.py", line 487, in run_setup
pdm.termui:     super().run_setup(setup_script=setup_script)
pdm.termui:   File "/tmp/pdm-build-env-47m8wddi-shared/lib/python3.11/site-packages/setuptools/build_meta.py", line 311, in run_setup
pdm.termui:     exec(code, locals())
pdm.termui:   File "<string>", line 19, in <module>
pdm.termui: ImportError: pip is not installed, refer to <http://pip.readthedocs.org> for instructions.
  ✖ Install bitstream 3.0.1 failed
pdm.termui: Error occurs: 
Traceback (most recent call last):
  File "/usr/lib/python3.11/concurrent/futures/thread.py", line 58, in run
    result = self.fn(*self.args, **self.kwargs)
             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/dirk/.local/share/pdm/venv/lib/python3.11/site-packages/pdm/installers/synchronizers.py", line 286, in install_candidate
    self.manager.install(can)
  File "/home/dirk/.local/share/pdm/venv/lib/python3.11/site-packages/pdm/installers/manager.py", line 34, in install
    dist_info = installer(str(prepared.build()), self.environment, prepared.direct_url())
                              ^^^^^^^^^^^^^^^^
  File "/home/dirk/.local/share/pdm/venv/lib/python3.11/site-packages/pdm/models/candidates.py", line 418, in build
    self.wheel = Path(builder.build(build_dir, metadata_directory=self._metadata_dir))
                      ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/dirk/.local/share/pdm/venv/lib/python3.11/site-packages/pdm/builders/wheel.py", line 26, in build
    requires = self._hook.get_requires_for_build_wheel(config_settings)
               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/dirk/.local/share/pdm/venv/lib/python3.11/site-packages/pyproject_hooks/_impl.py", line 166, in get_requires_for_build_wheel
    return self._call_hook('get_requires_for_build_wheel', {
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/dirk/.local/share/pdm/venv/lib/python3.11/site-packages/pyproject_hooks/_impl.py", line 311, in _call_hook
    self._subprocess_runner(
  File "/home/dirk/.local/share/pdm/venv/lib/python3.11/site-packages/pdm/builders/base.py", line 261, in subprocess_runner
    return log_subprocessor(cmd, cwd, extra_environ=env)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/dirk/.local/share/pdm/venv/lib/python3.11/site-packages/pdm/builders/base.py", line 107, in log_subprocessor
    raise build_error(e) from None
pdm.exceptions.BuildError: Build backend raised error: Showing the last 10 lines of the build output:
    return self._get_build_requires(config_settings, requirements=['wheel'])
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/tmp/pdm-build-env-47m8wddi-shared/lib/python3.11/site-packages/setuptools/build_meta.py", line 295, in _get_build_requires
    self.run_setup()
  File "/tmp/pdm-build-env-47m8wddi-shared/lib/python3.11/site-packages/setuptools/build_meta.py", line 487, in run_setup
    super().run_setup(setup_script=setup_script)
  File "/tmp/pdm-build-env-47m8wddi-shared/lib/python3.11/site-packages/setuptools/build_meta.py", line 311, in run_setup
    exec(code, locals())
  File "<string>", line 19, in <module>
ImportError: pip is not installed, refer to <http://pip.readthedocs.org> for instructions.
Retry failed jobs
pdm.termui: Preparing environment(Isolated mode) for PEP 517 build...
pdm.termui: Saving wheel to cache: <Link https://files.pythonhosted.org/packages/85/bc/60cc42dbc7d2ab0ff6caefd1a28c322f8c769261c48f1e67fd727c01e5fc/bitstream-3.0.1.tar.gz (from https://pypi.org/simple/bitstream/)>
pdm.termui: Running PEP 517 backend to build a wheel for <Link https://files.pythonhosted.org/packages/85/bc/60cc42dbc7d2ab0ff6caefd1a28c322f8c769261c48f1e67fd727c01e5fc/bitstream-3.0.1.tar.gz (from https://pypi.org/simple/bitstream/)>
pdm.termui: Traceback (most recent call last):
pdm.termui:   File "<string>", line 16, in <module>
pdm.termui: ModuleNotFoundError: No module named 'pip'
pdm.termui: 
pdm.termui: During handling of the above exception, another exception occurred:
pdm.termui: 
pdm.termui: Traceback (most recent call last):
pdm.termui:   File "/home/dirk/.local/share/pdm/venv/lib/python3.11/site-packages/pyproject_hooks/_in_process/_in_process.py", line 353, in <module>
pdm.termui:     main()
pdm.termui:   File "/home/dirk/.local/share/pdm/venv/lib/python3.11/site-packages/pyproject_hooks/_in_process/_in_process.py", line 335, in main
pdm.termui:     json_out['return_val'] = hook(**hook_input['kwargs'])
pdm.termui:                              ^^^^^^^^^^^^^^^^^^^^^^^^^^^^
pdm.termui:   File "/home/dirk/.local/share/pdm/venv/lib/python3.11/site-packages/pyproject_hooks/_in_process/_in_process.py", line 118, in get_requires_for_build_wheel
pdm.termui:     return hook(config_settings)
pdm.termui:            ^^^^^^^^^^^^^^^^^^^^^
pdm.termui:   File "/tmp/pdm-build-env-47m8wddi-shared/lib/python3.11/site-packages/setuptools/build_meta.py", line 325, in get_requires_for_build_wheel
pdm.termui:     return self._get_build_requires(config_settings, requirements=['wheel'])
pdm.termui:            ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
pdm.termui:   File "/tmp/pdm-build-env-47m8wddi-shared/lib/python3.11/site-packages/setuptools/build_meta.py", line 295, in _get_build_requires
pdm.termui:     self.run_setup()
pdm.termui:   File "/tmp/pdm-build-env-47m8wddi-shared/lib/python3.11/site-packages/setuptools/build_meta.py", line 487, in run_setup
pdm.termui:     super().run_setup(setup_script=setup_script)
pdm.termui:   File "/tmp/pdm-build-env-47m8wddi-shared/lib/python3.11/site-packages/setuptools/build_meta.py", line 311, in run_setup
pdm.termui:     exec(code, locals())
pdm.termui:   File "<string>", line 19, in <module>
pdm.termui: ImportError: pip is not installed, refer to <http://pip.readthedocs.org> for instructions.
  ✖ Install bitstream 3.0.1 failed
pdm.termui: Error occurs: 
Traceback (most recent call last):
  File "/usr/lib/python3.11/concurrent/futures/thread.py", line 58, in run
    result = self.fn(*self.args, **self.kwargs)
             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/dirk/.local/share/pdm/venv/lib/python3.11/site-packages/pdm/installers/synchronizers.py", line 286, in install_candidate
    self.manager.install(can)
  File "/home/dirk/.local/share/pdm/venv/lib/python3.11/site-packages/pdm/installers/manager.py", line 34, in install
    dist_info = installer(str(prepared.build()), self.environment, prepared.direct_url())
                              ^^^^^^^^^^^^^^^^
  File "/home/dirk/.local/share/pdm/venv/lib/python3.11/site-packages/pdm/models/candidates.py", line 418, in build
    self.wheel = Path(builder.build(build_dir, metadata_directory=self._metadata_dir))
                      ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/dirk/.local/share/pdm/venv/lib/python3.11/site-packages/pdm/builders/wheel.py", line 26, in build
    requires = self._hook.get_requires_for_build_wheel(config_settings)
               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/dirk/.local/share/pdm/venv/lib/python3.11/site-packages/pyproject_hooks/_impl.py", line 166, in get_requires_for_build_wheel
    return self._call_hook('get_requires_for_build_wheel', {
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/dirk/.local/share/pdm/venv/lib/python3.11/site-packages/pyproject_hooks/_impl.py", line 311, in _call_hook
    self._subprocess_runner(
  File "/home/dirk/.local/share/pdm/venv/lib/python3.11/site-packages/pdm/builders/base.py", line 261, in subprocess_runner
    return log_subprocessor(cmd, cwd, extra_environ=env)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/dirk/.local/share/pdm/venv/lib/python3.11/site-packages/pdm/builders/base.py", line 107, in log_subprocessor
    raise build_error(e) from None
pdm.exceptions.BuildError: Build backend raised error: Showing the last 10 lines of the build output:
    return self._get_build_requires(config_settings, requirements=['wheel'])
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/tmp/pdm-build-env-47m8wddi-shared/lib/python3.11/site-packages/setuptools/build_meta.py", line 295, in _get_build_requires
    self.run_setup()
  File "/tmp/pdm-build-env-47m8wddi-shared/lib/python3.11/site-packages/setuptools/build_meta.py", line 487, in run_setup
    super().run_setup(setup_script=setup_script)
  File "/tmp/pdm-build-env-47m8wddi-shared/lib/python3.11/site-packages/setuptools/build_meta.py", line 311, in run_setup
    exec(code, locals())
  File "<string>", line 19, in <module>
ImportError: pip is not installed, refer to <http://pip.readthedocs.org> for instructions.
Traceback (most recent call last):
  File "/home/dirk/.local/bin/pdm", line 8, in <module>
    sys.exit(main())
             ^^^^^^
  File "/home/dirk/.local/share/pdm/venv/lib/python3.11/site-packages/pdm/core.py", line 288, in main
    return Core().main(args or sys.argv[1:])
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/dirk/.local/share/pdm/venv/lib/python3.11/site-packages/pdm/core.py", line 208, in main
    raise cast(Exception, err).with_traceback(traceback) from None
  File "/home/dirk/.local/share/pdm/venv/lib/python3.11/site-packages/pdm/core.py", line 203, in main
    self.handle(project, options)
  File "/home/dirk/.local/share/pdm/venv/lib/python3.11/site-packages/pdm/core.py", line 157, in handle
    command.handle(project, options)
  File "/home/dirk/.local/share/pdm/venv/lib/python3.11/site-packages/pdm/cli/commands/add.py", line 69, in handle
    self.do_add(
  File "/home/dirk/.local/share/pdm/venv/lib/python3.11/site-packages/pdm/cli/commands/add.py", line 178, in do_add
    do_sync(
  File "/home/dirk/.local/share/pdm/venv/lib/python3.11/site-packages/pdm/cli/actions.py", line 237, in do_sync
    synchronizer.synchronize()
  File "/home/dirk/.local/share/pdm/venv/lib/python3.11/site-packages/pdm/installers/synchronizers.py", line 454, in synchronize
    raise InstallationError("Some package operations are not complete yet")
pdm.exceptions.InstallationError: Some package operations are not complete yet


Expected behavior

The dependency should install without issues

Environment Information


pdm info && pdm info --env

PDM version:
  2.12.3
Python Interpreter:
  /home/dirk/devel/pdmtest/.venv/bin/python (3.11)
Project Root:
  /home/dirk/devel/pdmtest
Local Packages:
  
{
  "implementation_name": "cpython",
  "implementation_version": "3.11.8",
  "os_name": "posix",
  "platform_machine": "x86_64",
  "platform_release": "6.6.15-amd64",
  "platform_system": "Linux",
  "platform_version": "#1 SMP PREEMPT_DYNAMIC Debian 6.6.15-2 (2024-02-04)",
  "python_full_version": "3.11.8",
  "platform_python_implementation": "CPython",
  "python_version": "3.11",
  "sys_platform": "linux"
}

@vhdirk vhdirk added the 🐛 bug Something isn't working label Feb 23, 2024
@pawamoy
Copy link
Contributor

pawamoy commented Feb 23, 2024

It looks like bitstream makes the wrong assumption that pip is always installed. The venv created by PDM does not have pip installed, so it fails. The right thing to do is that bitstream starts listing pip as a build requirement (feel free to reach out to the maintainers). In the meantime, you can also install pip within your venv, or delete the venv and recreate it with pdm venv create --with-pip, then try again pdm add bitstream.

@pawamoy pawamoy removed the 🐛 bug Something isn't working label Feb 23, 2024
@pawamoy
Copy link
Contributor

pawamoy commented Feb 23, 2024

I'm going to close this now since there's nothing actionable for PDM 🙂

@pawamoy pawamoy closed this as completed Feb 23, 2024
@vhdirk
Copy link
Author

vhdirk commented Feb 23, 2024

I've tried both your suggestions, but neither works.

The venv now contains pip

pdm run which pip 
/home/dirk/devel/pdmtest/.venv/bin/pip

But the error remains exactly the same

EDIT: It is indeed an error at the side of bitstream: boisgera/bitstream#29

Thanks for your quick response!

@pawamoy
Copy link
Contributor

pawamoy commented Feb 23, 2024

Ah, sorry, you need to opt-out of isolation mode: pdm add bitstream --no-isolation, so that it can use pip from your venv 🙂

# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants