This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

classification
Title: Cannot run pip in fresh install of py 3.5.3
Type: behavior Stage: resolved
Components: Documentation, Installation, Windows Versions: Python 3.10, Python 3.9, Python 3.8
process
Status: closed Resolution: fixed
Dependencies: Superseder:
Assigned To: docs@python Nosy List: Adrian Chan, docs@python, eryksun, paul.moore, steve.dower, tim.golden, zach.ware
Priority: normal Keywords:

Created on 2017-02-17 10:48 by Adrian Chan, last changed 2022-04-11 14:58 by admin. This issue is now closed.

Files
File name Uploaded Description Edit
import_logs.tar.gz Adrian Chan, 2017-02-17 13:20 verbose log showing import search
py_install_logs.tar.gz Adrian Chan, 2017-02-17 17:00 Python install logs from %TEMP%
Messages (14)
msg287986 - (view) Author: Adrian Chan (Adrian Chan) Date: 2017-02-17 10:48
I uninstalled python 2.7 and 3.4, then performed a fresh install of 3.5.3.
Running pip with `python -m pip` as per https://docs.python.org/3.5/installing gives the following error:

C:\Python\Python35-32\python.exe: No module named pip.__main__; 'pip' is a package and cannot be directly executed

Installation details:
*  win 7 64 bit.
*  python 3.5.3 32 bit.
*  chose options for pip, tcl/tk/idle, test suite, py launcher, shortcuts, add to env, precompile std lib.
*  installed to non-standard directory.
msg287994 - (view) Author: Eryk Sun (eryksun) * (Python triager) Date: 2017-02-17 11:59
Please provide the complete traceback. Copy and paste it from the command prompt. Also, include the fully-qualified path for what "python" runs, e.g. run `where python` in the command prompt. Also, include the value of the environment variables PYTHONHOME and PYTHONPATH, e.g. run `echo %PYTHONHOME% & echo %PYTHONPATH%` in the command prompt.
msg287998 - (view) Author: Adrian Chan (Adrian Chan) Date: 2017-02-17 12:12
There is no traceback, that is the entirety of the output of the command.

Python bin is C:\Python\Python35-32\python.exe
PYTHONHOME is not set.
PYTHONPATH is C:\python27\lib\site-packages\

I don't know why PYTHONPATH was set.  I cleared it but it made no difference -- same error.
msg288002 - (view) Author: Eryk Sun (eryksun) * (Python triager) Date: 2017-02-17 12:53
That error looks like __init__.py[c] was left in "C:\python27\lib\site-packages\pip". Just to be sure, since I don't know what you did to clear the value, please run `set PYTHONPATH=` to clear the value for the current shell. Then try `python -m pip`.

When you modify or remove an environment variable using the control panel dialog, it broadcasts a window message that causes Explorer to reload its environment. Generally console applications such as cmd.exe do not own a top-level window (the console window is owned by conhost.exe) and thus cannot see this broadcasted message. To get the updated environment, you have to run a new instance of cmd from Explorer.
msg288004 - (view) Author: Adrian Chan (Adrian Chan) Date: 2017-02-17 13:20
Thanks, but I know how to drive a terminal ;)

Your hunch was basically correct though.  I ran again with `python -v -m pip` (see with_pip_dir.txt), and see that python is attempting to import pip from my user directory (C:\Users\amc2\pip).  This is an empty directory, except for an old pip log file from 2.7.

If I rename the directory to something unrelated, `python -m pip` just fails with:

C:\Python\Python35-32\python.exe: No module named pip.

So mystery 1 is solved.

I've definitely selected the pip option in the python installer.  I also repaired the installation, with the pip option selected, and the error still remains.
Where is pip supposed to be located on a win7 install?
msg288007 - (view) Author: Eryk Sun (eryksun) * (Python triager) Date: 2017-02-17 13:55
pip should be installed in site-packages, which for you is "C:\Python\Python35-32\Lib\site-packages". Try manually running ensurepip to make sure pip is installed:

    python -m ensurepip --verbose --upgrade --default-pip
msg288008 - (view) Author: Adrian Chan (Adrian Chan) Date: 2017-02-17 14:13
It's all working fine now, thanks.

If one of the installer/windows guys wants to dig more into why this didn't install properly I'm happy to run things in my environment as necessary.
msg288009 - (view) Author: Eryk Sun (eryksun) * (Python triager) Date: 2017-02-17 14:22
If you have the 3.5 installation logs in your %TEMP% directory, please zip them up and attach them to this issue.
msg288022 - (view) Author: Adrian Chan (Adrian Chan) Date: 2017-02-17 17:00
Install logs attached.
First set from initial install, second set from repair.
msg288034 - (view) Author: Eryk Sun (eryksun) * (Python triager) Date: 2017-02-17 19:20
The original install failed with the status code STATUS_DLL_NOT_FOUND (0xC0000135), as reported in "Python 3.5.3 (32-bit)_20170217102132_008_pip_JustForMe.log":

    MSI (s) (88:D8) [10:22:59:574]: Executing op: ActionStart(Name=UpdatePip,,)
    MSI (s) (88:D8) [10:22:59:575]: Executing op: CustomActionSchedule(
        Action=UpdatePip,ActionType=1089, Source=BinaryData,Target=CAQuietExec,
        CustomActionData="C:\Python\Python35-32\python.exe" -E -s -m ensurepip -U --default-pip)
    MSI (s) (88:C4) [10:22:59:588]: Invoking remote custom action.
        DLL: C:\Windows\Installer\MSI2C60.tmp,
        Entrypoint: CAQuietExec
    MSI (s) (88:B0) [10:22:59:588]: Generating random cookie.
    MSI (s) (88:B0) [10:22:59:590]: Created Custom Action Server with PID 6212 (0x1844).
    MSI (s) (88:A8) [10:22:59:630]: Running as a service.
    MSI (s) (88:A8) [10:22:59:631]: Hello, I'm your 32bit Impersonated custom action server.
    CAQuietExec:  Error 0xc0000135: Command line returned an error.
    CAQuietExec:  Error 0xc0000135: QuietExec Failed
    CAQuietExec:  Error 0xc0000135: Failed in ExecCommon method
    MSI (s) (88:D8) [10:22:59:658]: Executing op: End(Checksum=0,
        ProgressTotalHDWord=0,ProgressTotalLDWord=287056)
        CustomAction UpdatePip returned actual error code 1603 but will be
        translated to success due to continue marking

Did your system require a reboot for Python 3.5 to work?

From what I can see in "Python 3.5.3 (32-bit)_20170217131555_007_pip_JustForMe.log", it looks like the repair skipped installing pip. 

    MSI (s) (D8:1C) [13:16:31:822]: Skipping action: SetRemovePipCommandLine (condition is false)
    MSI (s) (D8:1C) [13:16:31:822]: Skipping action: SetUpdatePipCommandLine (condition is false)
    MSI (s) (D8:1C) [13:16:31:822]: Skipping action: UpdatePip (condition is false)
    MSI (s) (D8:1C) [13:16:31:822]: Doing action: InstallFinalize
    MSI (s) (D8:1C) [13:16:31:822]: Note: 1: 2205 2:  3: ActionText 
    Action ended 13:16:31: PublishProduct. Return value 1.

Maybe Steve Dower can shed light on why a repair with pip selected didn't try to install pip.
msg288035 - (view) Author: Steve Dower (steve.dower) * (Python committer) Date: 2017-02-17 20:13
Depending on why the pip install failed, we may still have registered that it was installed. IIRC, we only trigger the install on a state change, which wouldn't happen in repair. That deserves its own bug (though maybe this one will suffice if we figure out the original failure - I haven't looked at the logs yet)
msg288201 - (view) Author: Adrian Chan (Adrian Chan) Date: 2017-02-20 13:31
Ah, I'd forgotten about that.  When I first tried to run python I got an error complaining about a missing api-ms-win-crt-runtime-l1-1.0.dll
I installed the necessary VC redistributable and it solved that problem.  So that's why I could successfully ensurepip later on.

I'm surprised the manual runtime installation was necessary.  Between windows updates and installers for other programs I should already have it installed.  Perhaps it got corrupted?  That's out of scope for this issue anyway.
msg388634 - (view) Author: Eryk Sun (eryksun) * (Python triager) Date: 2021-03-13 19:38
This issue is similar to bpo-25117 in terms of the installer failing to run Python for post-installation tasks. The complication in this case is that a subsequent repair doesn't install pip.
msg388778 - (view) Author: Steve Dower (steve.dower) * (Python committer) Date: 2021-03-15 22:14
This was caused by the UCRT not installing properly. These days, the UCRT is installed app-local for Win 8.1, and is already present on Win 10, so it can't happen anymore.
History
Date User Action Args
2022-04-11 14:58:43adminsetgithub: 73772
2021-03-15 22:14:22steve.dowersetstatus: open -> closed
resolution: fixed
messages: + msg388778

stage: resolved
2021-03-13 19:38:13eryksunsetmessages: + msg388634
versions: + Python 3.8, Python 3.9, Python 3.10, - Python 3.5
2017-02-20 13:31:24Adrian Chansetmessages: + msg288201
2017-02-17 20:13:46steve.dowersetmessages: + msg288035
2017-02-17 19:20:15eryksunsetmessages: + msg288034
2017-02-17 17:00:56Adrian Chansetfiles: + py_install_logs.tar.gz

messages: + msg288022
2017-02-17 14:22:18eryksunsetmessages: + msg288009
2017-02-17 14:13:09Adrian Chansetmessages: + msg288008
2017-02-17 13:55:06eryksunsetmessages: + msg288007
2017-02-17 13:20:57Adrian Chansetfiles: + import_logs.tar.gz

messages: + msg288004
2017-02-17 12:53:23eryksunsetmessages: + msg288002
2017-02-17 12:12:04Adrian Chansetmessages: + msg287998
2017-02-17 11:59:37eryksunsetnosy: + eryksun
messages: + msg287994
2017-02-17 10:48:03Adrian Chancreate