Pip not working/not installed with 3.12.4

ive tried installing with ensurepip, which gave this:

E:\Documents\projects\beatdeck>py -m ensurepip
Traceback (most recent call last):
  File "<string>", line 6, in <module>
  File "<frozen runpy>", line 226, in run_module
  File "<frozen runpy>", line 98, in _run_module_code
  File "<frozen runpy>", line 88, in _run_code
  File "E:\Temp\tmpl14o_oxd\pip-24.0-py3-none-any.whl\pip\__main__.py", line 22, in <module>
  File "E:\Temp\tmpl14o_oxd\pip-24.0-py3-none-any.whl\pip\_internal\cli\main.py", line 10, in <module>
  File "E:\Temp\tmpl14o_oxd\pip-24.0-py3-none-any.whl\pip\_internal\cli\autocompletion.py", line 10, in <module>
  File "E:\Temp\tmpl14o_oxd\pip-24.0-py3-none-any.whl\pip\_internal\cli\main_parser.py", line 9, in <module>
  File "E:\Temp\tmpl14o_oxd\pip-24.0-py3-none-any.whl\pip\_internal\build_env.py", line 19, in <module>
  File "E:\Temp\tmpl14o_oxd\pip-24.0-py3-none-any.whl\pip\_internal\cli\spinners.py", line 9, in <module>
  File "E:\Temp\tmpl14o_oxd\pip-24.0-py3-none-any.whl\pip\_internal\utils\logging.py", line 29, in <module>
  File "E:\Temp\tmpl14o_oxd\pip-24.0-py3-none-any.whl\pip\_internal\utils\misc.py", line 40, in <module>
  File "E:\Temp\tmpl14o_oxd\pip-24.0-py3-none-any.whl\pip\_vendor\tenacity\__init__.py", line 548, in <module>
  File "E:\Temp\tmpl14o_oxd\pip-24.0-py3-none-any.whl\pip\_vendor\tenacity\_asyncio.py", line 21, in <module>
  File "E:\Apps\pip\asyncio\__init__.py", line 21, in <module>
    from .base_events import *
  File "E:\Apps\pip\asyncio\base_events.py", line 296
    future = tasks.async(future, loop=self)
                   ^^^^^
SyntaxError: invalid syntax
Traceback (most recent call last):
  File "<frozen runpy>", line 198, in _run_module_as_main
  File "<frozen runpy>", line 88, in _run_code
  File "E:\Apps\Python312\Lib\ensurepip\__main__.py", line 5, in <module>
    sys.exit(ensurepip._main())
             ^^^^^^^^^^^^^^^^^
  File "E:\Apps\Python312\Lib\ensurepip\__init__.py", line 284, in _main
    return _bootstrap(
           ^^^^^^^^^^^
  File "E:\Apps\Python312\Lib\ensurepip\__init__.py", line 200, in _bootstrap
    return _run_pip([*args, *_PACKAGE_NAMES], additional_paths)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "E:\Apps\Python312\Lib\ensurepip\__init__.py", line 101, in _run_pip
    return subprocess.run(cmd, check=True).returncode
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "E:\Apps\Python312\Lib\subprocess.py", line 571, in run
    raise CalledProcessError(retcode, process.args,
subprocess.CalledProcessError: Command '['E:\\Apps\\Python312\\python.exe', '-W', 'ignore::DeprecationWarning', '-c', '\nimport runpy\nimport sys\nsys.path = [\'E:\\\\Temp\\\\tmpl14o_oxd\\\\pip-24.0-py3-none-any.whl\'] + sys.path\nsys.argv[1:] = [\'install\', \'--no-cache-dir\', \'--no-index\', \'--find-links\', \'E:\\\\Temp\\\\tmpl14o_oxd\', \'pip\']\nrunpy.run_module("pip", run_name="__main__", alter_sys=True)\n']' returned non-zero exit status 1.

using get-pip.py gave this:

E:\Documents\projects\beatdeck>py E:\Downloads\get-pip.py 
Traceback (most recent call last):
  File "E:\Downloads\get-pip.py", line 28541, in <module>
    main()
  File "E:\Downloads\get-pip.py", line 135, in main
    bootstrap(tmpdir=tmpdir)
  File "E:\Downloads\get-pip.py", line 111, in bootstrap
    monkeypatch_for_cert(tmpdir)
  File "E:\Downloads\get-pip.py", line 92, in monkeypatch_for_cert
    from pip._internal.commands.install import InstallCommand
  File "E:\Temp\tmp4ff6hxmt\pip.zip\pip\_internal\commands\__init__.py", line 9, in <module>
  File "E:\Temp\tmp4ff6hxmt\pip.zip\pip\_internal\cli\base_command.py", line 15, in <module>
  File "E:\Temp\tmp4ff6hxmt\pip.zip\pip\_internal\cli\cmdoptions.py", line 24, in <module>
  File "E:\Temp\tmp4ff6hxmt\pip.zip\pip\_internal\cli\parser.py", line 12, in <module>
  File "E:\Temp\tmp4ff6hxmt\pip.zip\pip\_internal\configuration.py", line 26, in <module>
  File "E:\Temp\tmp4ff6hxmt\pip.zip\pip\_internal\utils\logging.py", line 29, in <module>
  File "E:\Temp\tmp4ff6hxmt\pip.zip\pip\_internal\utils\misc.py", line 39, in <module>
  File "E:\Temp\tmp4ff6hxmt\pip.zip\pip\_vendor\tenacity\__init__.py", line 548, in <module>
  File "E:\Temp\tmp4ff6hxmt\pip.zip\pip\_vendor\tenacity\_asyncio.py", line 21, in <module>
  File "E:\Apps\pip\asyncio\__init__.py", line 21, in <module>
    from .base_events import *
  File "E:\Apps\pip\asyncio\base_events.py", line 296
    future = tasks.async(future, loop=self)
                   ^^^^^
SyntaxError: invalid syntax

and the zipped standalone gave this:

E:\Documents\projects\beatdeck>py E:\Downloads\pip.pyz
Traceback (most recent call last):
  File "<frozen runpy>", line 198, in _run_module_as_main
  File "<frozen runpy>", line 88, in _run_code
  File "E:\Downloads\pip.pyz\__main__.py", line 26, in <module>
  File "<frozen runpy>", line 229, in run_module
  File "<frozen runpy>", line 88, in _run_code
  File "E:\Downloads\pip.pyz\pip\__main__.py", line 22, in <module>
  File "E:\Downloads\pip.pyz\pip\_internal\cli\main.py", line 11, in <module>
  File "E:\Downloads\pip.pyz\pip\_internal\cli\autocompletion.py", line 10, in <module>
  File "E:\Downloads\pip.pyz\pip\_internal\cli\main_parser.py", line 9, in <module>
  File "E:\Downloads\pip.pyz\pip\_internal\build_env.py", line 19, in <module>
  File "E:\Downloads\pip.pyz\pip\_internal\cli\spinners.py", line 9, in <module>
  File "E:\Downloads\pip.pyz\pip\_internal\utils\logging.py", line 29, in <module>
  File "E:\Downloads\pip.pyz\pip\_internal\utils\misc.py", line 39, in <module>
  File "E:\Downloads\pip.pyz\pip\_vendor\tenacity\__init__.py", line 548, in <module>
  File "E:\Downloads\pip.pyz\pip\_vendor\tenacity\_asyncio.py", line 21, in <module>
  File "E:\Apps\pip\asyncio\__init__.py", line 21, in <module>
    from .base_events import *
  File "E:\Apps\pip\asyncio\base_events.py", line 296
    future = tasks.async(future, loop=self)
                   ^^^^^
SyntaxError: invalid syntax

am i doing something wrong? i tried to make it come prebundled with python, but it wasn’t installed for some reason.

E:\Documents\projects\beatdeck>py -m pip
E:\Apps\Python312\python.exe: No module named pip

please help! thanks!

It’s complaining about some syntax in E:\Apps\pip\asyncio\base_events.py:

    future = tasks.async(future, loop=self)

because in Python 3.12 (and recent versions) async is a reserved word, so that’s invalid.

Where does E:\Apps\pip come from?

The installer should’ve installed pip anyway, unless the option was turned off.

It looks like Python is finding that and trying to use it, but it’s invalid. (Maybe it’s from some versions back before async became a reserved word.)

If E:\Apps\pip is listed in the system path, try removing it, or renaming that folder to something else, or just deleting it (it won’t work any more anyway).

Every attempt fails the same way:

What happens here is:

  • When you install Pip, since you don’t already have Pip, some other mechanism has to start with a pre-made set of Pip files. But the various installers for Pip don’t actually implement the logic for installing third-party libraries (like, well, Pip). Instead, basically they set up a temporary folder with just the Pip code, then run (in a separate process) that code to make Pip install itself.

  • In general, Pip has dependencies that would otherwise normally be installed by Pip, from PyPI. But this is a chicken-and-egg problem - without those dependencies already being available, Pip wouldn’t be able to install anything. (The dependencies help it do things like connect to PyPI, parse package metadata, display nice coloured text and progress bars in the terminal, etc.)

  • The asyncio standard library was added in Python 3.4. A backport was published on PyPI so that Python 3.3 users could have the same functionality. But this code used async as a variable name originally, and in Python 3.5, async became a keyword. So this library is only needed on exactly 3.3, irrelevant on 3.4, and potentially breaks things on every version after that (unless you got a sufficiently updated version, but it’s still useless).

  • When Python does an absolute import, it searches the sys.path in order. It gives priority to only built-in standard library modules (where the implementation is actually compiled directly into the Python interpreter, like for sys). For the rest of the standard library, it’s very likely that code from the current project will be able to shadow it:

  • For Pip 24.0, one of Pip’s dependencies is tenacity (a library used for retrying operations that might periodically fail). At line 21, it tries to import the function sleep from the standard library asyncio module.

  • But for whatever reason, you appear to have E:\Apps\pip on your sys.path, and it contains the asyncio backport. (You should take steps to figure out why.)

  • Therefore, when the Pip bootstrap is… bootstrapping, it fails to find the standard library asyncio, finding the broken backport instead. (Based on the line number in the error, and cross-referencing a bunch of stuff in the GitHub history, it’s the latest tagged release.)

I did a ridiculous amount of digging around to try to come up with a plausible reason why you have this E:\Apps\pip\asyncio folder in the first place, but came up empty-handed. As far as I can tell, Pip never vendored the backport directly, and back in that era, Pip was using a different library for re-trying stuff (more plainly called retrying) which doesn’t appear to have supported asynchronous retries at all.