conda-forge / python-feedstock

A conda-smithy repository for python.
BSD 3-Clause "New" or "Revised" License
46 stars 105 forks source link

pip 20 broken for python 2.7 #694

Closed pbordron closed 4 months ago

pbordron commented 4 months ago

Solution to issue cannot be found in the documentation.

Issue

I need to use python 2.7 for some old scripts. The pip (20.*) installed with it is broken. I got an ImportError: No module named pip._internal.cli.main when trying to use it (details at the end of this section).

When searching for pip package in $CONDA_PREFIX, I found that the package is not installed in $CONDA_PREFIX/lib/python2.7, but at the root of the env (the 2 first lines of the following find command)

$ find $CONDA_PREFIX/ -name "*pip*"
/home/<user>/miniconda3/envs/py27/site-packages/pip
/home/<user>/miniconda3/envs/py27/site-packages/pip-20.1.1-py3.6.egg-info
/home/<user>/miniconda3/envs/py27/bin/pip
/home/<user>/miniconda3/envs/py27/conda-meta/pip-20.1.1-pyh9f0ad1d_0.json
/home/<user>/miniconda3/envs/py27/lib/python2.7/pipes.pyc
/home/<user>/miniconda3/envs/py27/lib/python2.7/pipes.py
/home/<user>/miniconda3/envs/py27/lib/python2.7/ensurepip
/home/<user>/miniconda3/envs/py27/lib/python2.7/ensurepip/_bundled/pip-9.0.3-py2.py3-none-any.whl

Installing a pip <20 solve the issue, but a broken version of pip mustn't be installed by default.

The ImportError details:

$ conda create -n py27 python=2.7
Channels:
 - conda-forge
 - bioconda
 - local
 - defaults
Platform: linux-64
Collecting package metadata (repodata.json): done
Solving environment: done

## Package Plan ##

  environment location: /home/<user>/miniconda3/envs/py27

  added / updated specs:
    - python=2.7

The following packages will be downloaded:

    package                    |            build
    ---------------------------|-----------------
    _libgcc_mutex-0.1          |      conda_forge           3 KB  conda-forge
    _openmp_mutex-4.5          |            2_gnu          23 KB  conda-forge
    libzlib-1.2.13             |       h4ab18f5_6          60 KB  conda-forge
    python_abi-2.7             |         1_cp27mu           4 KB  conda-forge
    zlib-1.2.13                |       h4ab18f5_6          91 KB  conda-forge
    ------------------------------------------------------------
                                           Total:         180 KB

The following NEW packages will be INSTALLED:

  _libgcc_mutex      conda-forge/linux-64::_libgcc_mutex-0.1-conda_forge 
  _openmp_mutex      conda-forge/linux-64::_openmp_mutex-4.5-2_gnu 
  ca-certificates    conda-forge/linux-64::ca-certificates-2024.7.4-hbcca054_0 
  certifi            conda-forge/linux-64::certifi-2019.11.28-py27h8c360ce_1 
  ld_impl_linux-64   conda-forge/linux-64::ld_impl_linux-64-2.40-hf3520f5_7 
  libffi             conda-forge/linux-64::libffi-3.2.1-he1b5a44_1007 
  libgcc-ng          conda-forge/linux-64::libgcc-ng-14.1.0-h77fa898_0 
  libgomp            conda-forge/linux-64::libgomp-14.1.0-h77fa898_0 
  libsqlite          conda-forge/linux-64::libsqlite-3.46.0-hde9e2c9_0 
  libstdcxx-ng       conda-forge/linux-64::libstdcxx-ng-14.1.0-hc0a3c3a_0 
  libzlib            conda-forge/linux-64::libzlib-1.2.13-h4ab18f5_6 
  ncurses            conda-forge/linux-64::ncurses-6.5-h59595ed_0 
  openssl            conda-forge/linux-64::openssl-1.1.1w-hd590300_0 
  pip                conda-forge/noarch::pip-20.1.1-pyh9f0ad1d_0 
  python             conda-forge/linux-64::python-2.7.15-h5a48372_1011_cpython 
  python_abi         conda-forge/linux-64::python_abi-2.7-1_cp27mu 
  readline           conda-forge/linux-64::readline-8.2-h8228510_1 
  setuptools         conda-forge/linux-64::setuptools-44.0.0-py27_0 
  sqlite             conda-forge/linux-64::sqlite-3.46.0-h6d4b2fc_0 
  tk                 conda-forge/linux-64::tk-8.6.13-noxft_h4845f30_101 
  wheel              conda-forge/noarch::wheel-0.37.1-pyhd8ed1ab_0 
  zlib               conda-forge/linux-64::zlib-1.2.13-h4ab18f5_6 

Proceed ([y]/n)? 

Downloading and Extracting Packages:

Preparing transaction: done                                                                                                                                     
Verifying transaction: done                                                                                                                                     
Executing transaction: done                                                                                                                                     
#                                                                                                                                                               
# To activate this environment, use
#
#     $ conda activate py27
#
# To deactivate an active environment, use
#
#     $ conda deactivate

$ conda activate py27

$ pip --help
Traceback (most recent call last):
  File "/home/<user>/miniconda3/envs/py27/bin/pip", line 6, in <module>
    from pip._internal.cli.main import main
ImportError: No module named pip._internal.cli.main

Installed packages

$ conda list
# packages in environment at /home/<user>/miniconda3/envs/py27:
#
# Name                    Version                   Build  Channel
_libgcc_mutex             0.1                 conda_forge    conda-forge
_openmp_mutex             4.5                       2_gnu    conda-forge
ca-certificates           2024.7.4             hbcca054_0    conda-forge
certifi                   2019.11.28       py27h8c360ce_1    conda-forge
ld_impl_linux-64          2.40                 hf3520f5_7    conda-forge
libffi                    3.2.1             he1b5a44_1007    conda-forge
libgcc-ng                 14.1.0               h77fa898_0    conda-forge
libgomp                   14.1.0               h77fa898_0    conda-forge
libsqlite                 3.46.0               hde9e2c9_0    conda-forge
libstdcxx-ng              14.1.0               hc0a3c3a_0    conda-forge
libzlib                   1.2.13               h4ab18f5_6    conda-forge
ncurses                   6.5                  h59595ed_0    conda-forge
openssl                   1.1.1w               hd590300_0    conda-forge
pip                       20.1.1             pyh9f0ad1d_0    conda-forge
python                    2.7.15          h5a48372_1011_cpython    conda-forge
python_abi                2.7                    1_cp27mu    conda-forge
readline                  8.2                  h8228510_1    conda-forge
setuptools                44.0.0                   py27_0    conda-forge
sqlite                    3.46.0               h6d4b2fc_0    conda-forge
tk                        8.6.13          noxft_h4845f30_101    conda-forge
wheel                     0.37.1             pyhd8ed1ab_0    conda-forge
zlib                      1.2.13               h4ab18f5_6    conda-forge

### Environment info

```shell
active environment : py27
    active env location : /home/<user>/miniconda3/envs/py27
            shell level : 1
       user config file : /home/<user>/.condarc
 populated config files : /home/<user>/.condarc
          conda version : 24.5.0
    conda-build version : 24.5.1
         python version : 3.12.4.final.0
                 solver : libmamba (default)
       virtual packages : __archspec=1=icelake
                          __conda=24.5.0=0
                          __glibc=2.31=0
                          __linux=5.15.0=0
                          __unix=0=0
       base environment : /home/<user>/miniconda3  (writable)
      conda av data dir : /home/<user>/miniconda3/etc/conda
  conda av metadata url : None
           channel URLs : https://conda.anaconda.org/conda-forge/linux-64
                          https://conda.anaconda.org/conda-forge/noarch
                          https://conda.anaconda.org/bioconda/linux-64
                          https://conda.anaconda.org/bioconda/noarch
                          file:///home/<user>/miniconda3/conda-bld/linux-64
                          file:///home/<user>/miniconda3/conda-bld/noarch
                          https://repo.anaconda.com/pkgs/main/linux-64
                          https://repo.anaconda.com/pkgs/main/noarch
                          https://repo.anaconda.com/pkgs/r/linux-64
                          https://repo.anaconda.com/pkgs/r/noarch
          package cache : /home/<user>/miniconda3/pkgs
                          /home/<user>/.conda/pkgs
       envs directories : /home/<user>/miniconda3/envs
                          /home/<user>/.conda/envs
               platform : linux-64
             user-agent : conda/24.5.0 requests/2.32.3 CPython/3.12.4 Linux/5.15.0-113-generic linuxmint/20.3 glibc/2.31 solver/libmamba conda-libmamba-solver/24.1.0 libmambapy/1.5.8
                UID:GID : 4063:500
             netrc file : None
           offline mode : False
pbordron commented 4 months ago

Sorry wrong place, I put the issue here conda-forge/pip-feedstock/issues/122