vxiiduu / VxKex

Windows 7 API Extensions
776 stars 47 forks source link

Python 3.12.3 installation issues #225

Open JakoDel opened 1 month ago

JakoDel commented 1 month ago

programs that the python setup installs like pip are unaccessible.

right after executing "python", I also get this: Could not find platform independent libraries

thanks a ton for your work.

edit: not a PATH issue as the Scripts folder is completely empty. on 3.8 pip does appear in the folder.

CommonLoon102 commented 1 month ago

have you tried this? https://github.com/vxiiduu/VxKex/issues/178#issuecomment-2041401835

JakoDel commented 1 month ago

have you tried this? #178 (comment)

thanks for the reply! 1.already installed

  1. this alone doesnt help, still complains about w8.1
  2. works without vxkex + no "Could not find platform independent libraries" but still doesnt install pip in /Scripts
i486 commented 4 weeks ago

A couple of weeks ago, I encountered this problem while experimenting with Python 3.11 and VxKex. Basically, when VxKex is activated, Python kind of goes haywire (you can easily verify this by running some commands from the \scripts folder). What's odd is that this issue doesn't happen with Python 3.10. I've attempted to compare logs and process environments from both versions but couldn't identify anything obvious.

As for alternatives like PythonWin7 or api-ms-win-core-path-HACK, I've come to realize that we can't reliably depend on them anymore after testing numerous Python apps this week. The problem is that there are already popular Python libraries or modules that import Win 8+ only APIs.

For example, here's a *.pyd file in the site-packages folder of a project that requires Python 3.11+. It imports two APIs exclusive to Windows 8 and above. VxKex can easily solve these APIs.

image

Since VxKex is currently incompatible with Python 3.11, I built the project on Python 3.10 (fortunately, it didn't rely on 3.11 features, or perhaps it did—I'm unsure, lol) and activated VxKex, effectively handling the Win 8+ only *.pyd library file.

Unfortunately, these kinds of Python packages will increase over time, just as the number of projects and applications requiring Python 3.11+

If there were a vote for what to prioritize next, I'd definitely cast my ballot for this.

NulAsh commented 2 weeks ago

Try this command: python -s -m ensurepip -U --default-pip It should install pip.

i486 commented 2 weeks ago

Try this command: python -s -m ensurepip -U --default-pip It should install pip.

In my case, I already have pip, etc., installed previously with the api-ms-win-core-path-l1-1-0 hack.

Python, pip, and all other scripts in the /scripts folder work fine.

image

However, if I activate VxKex on python.exe (Python311):

image

i486 commented 2 weeks ago

I launched cmd from this C:\I\Started\CMDfromHERE folder

VxKex Enabled

image

VxKex Disabled (using api-ms-win-core-path-l1-1-0.dll)

image

Definitely VxKex bug, right?

i486 commented 2 weeks ago

Here's the solution for running Python 3.11 and Python 3.12 under VxKex until a future update resolves the issue.

As seen in the screenshot from the previous post, enabling VxKex causes sys.path and sys.prefix initialization to result in incorrect paths.

Under normal conditions, sys.path should contain:

And sys.prefix should point to the directory of python.exe:

However, with VxKex enabled, Python 3.11+ incorrectly sets sys.path as:

And more importantly, following path is not included.

As for sys.prefix, It's incorrectly set to:

To fix this, you can use Python's special environment variables to forcefully add the correct paths.

  1. Add the following paths to the PYTHONPATH environment variable. This forces Python to include these paths in sys.path:

    C:\Users\PC\AppData\Local\Programs\Python\Python312\DLLs
    C:\Users\PC\AppData\Local\Programs\Python\Python312\Lib
    C:\Users\PC\AppData\Local\Programs\Python\Python312
    C:\Users\PC\AppData\Local\Programs\Python\Python312\Python312.zip
    C:\Users\PC\AppData\Local\Programs\Python\Python312\Lib\site-packages
  2. Set the PYTHONHOME environment variable to your Python 3.11+ installation directory. This adds the path to sys.prefix

    C:\Users\PC\AppData\Local\Programs\Python\Python312

    After making these changes, sys.path and sys.prefix should look correct:

Correct sys.path and sys.prefix

Now when running Python 3.12, the "Could not find platform independent libraries" error is gone because we added Lib\site-packages to sys.path.

No more error

However, attempting to install packages with pip results in an error.

Could not import runpy module
Traceback (most recent call last):
  File "C:\Users\PC\AppData\Local\Programs\Python\Python312\Lib\runpy.py", line 14, in <mo
dule>
    import importlib.machinery # importlib first so we can test #15386 via -m
  File "C:\Users\PC\AppData\Local\Programs\Python\Python312\Lib\importlib\machinery.py", l
ine 15, in <module>
    from ._bootstrap_external import NamespaceLoader
ImportError: cannot import name 'NamespaceLoader' from 'importlib._bootstrap_external' (C:
\Users\PC\AppData\Local\Programs\Python\Python312\Lib\importlib\_bootstrap_external.py)

This is a different issue related to the Python installer. To resolve it, use python -m ensurepip to install pip, then rename (or copy) pip3.exe to pip.exe in the Python312\Scripts folder, allowing you to type "pip" instead of "pip3".

C:\Users>python -m ensurepip
Looking in links: c:\Users\PC\AppData\Local\Temp\tmpmvanux2t
Processing c:\users\pc\appdata\local\temp\tmpmvanux2t\pip-24.0-py3-none-any.whl
Installing collected packages: pip
Successfully installed pip-24.0

Now try installing packages again:

Pip installation successful