Search code examples
pythonarcgisensurepip

Python package creation on Windows fails with „ … python.exe', '-Im', 'ensurepip', '--upgrade', '--default-pip']' returned non-zero exit status 1.“


I’m working on Windows with ArcGIS Pro and Python and I have a copied conda env from ArcGIS Pro. If I try to build a package the following error is displayed:

ERROR Command '['C:\\Users\\...\\AppData\\Local\\Temp\\build-env-lljm30w\\Scripts\\python.exe', '-Im', 'ensurepip', '--upgrade', '--default-pip']' returned non-zero exit status 1.

It worked before with an older ArcGIS Pro Version and I think I found the problem:

The .whl file in Lib\ensurepip_bundled is pip-21.1.3-py3-none-any.whl and not pip-20.1.1-py2.py3-none-any.whl

It works if I manually copy the „old“ .whl file (from a coworker with the older ArcGIS Pro Version - still trying to get the version details) in the directory before I start the build process.

Since this can’t be the solution, I’m still looking for one. Anything I need to update? From what I understand the _bundled directory can’t be updated since it is already a part of the python version. But why does the (integrated) build version needs an older pip.whl?

Could someone please help me.

Python: 3.7.11 Arcgis Pro: 2.9.2 pip: 22.0.4 build: 0.7.0


Solution

  • I had a similar situation: Upgrade ArcGIS Pro which subsequently upgraded the underlying python from 3.6 to 3.7.11. This tanked my ability to build virtual python environments on top of my ArcPro python. I had the same error message as you.

    Your question helped me narrow the problem to the ensurepip part of the equation. I followed the accepted answer on this page where a similar problem was recorded. So, I had to update the _PIP_VERSION variable to match my .whl file; in my case, this was 21.1.3 to match the file pip-21.1.3-py3-none-any.whl.

    But, additionally, we also have the py2.py3 issue (which the OP of the other question did not). To fix this, I edited the last item of the last list in the _PROJECTS variable to become "py3") instead of "py2.py3").

    After I made these two changes, I was able to install a venv to my ArcGIS-based python interpreter.

    So, lines 12-19 of my __init__.py for ensurepip now look like this:

    _SETUPTOOLS_VERSION = "47.1.0"
    
    _PIP_VERSION = "21.1.3"  # "20.1.1"
    
    _PROJECTS = [
        ("setuptools", _SETUPTOOLS_VERSION, "py3"),
        ("pip", _PIP_VERSION, "py3"),  # "py2.py3"),
    ]
    

    Hope this helps!