conda / conda

A system-level, binary package and environment manager running on all major operating systems and platforms.
https://docs.conda.io/projects/conda/
Other
6.45k stars 1.68k forks source link

Pip cannot establish a connection in a conda environment unless numpy-base is installed in WSL 1 #12051

Open duncanmcbryde opened 2 years ago

duncanmcbryde commented 2 years ago

Checklist

What happened?

If conda is installed in a WSL 1 Ubuntu environment, pip cannot connect to the internet when installed in an environment with python versions 3.7 and above. Creating a new environment with only pip and python causes pip to fail to establish connections, but when numpy-base is installed (and dependencies) pip is able to connect to PyPi.

This only affects WSL 1, it does not affect WSL 2.

I've confirmed this with multiple computers and a VM running Ubuntu 18.04, and it's consistent on conda versions 4.12, 4.14 and 22.9 on Ubuntu 18.04 freshly installed, as well as working on a new windows virtual machine.

To create a minimal test case, once conda is installed in a WSL 1, create a new environment called "test" with python 3.7 and pip and try to install pytz. This fails

conda create -y -n test python=3.7 pip && conda run -n test pip install pytz

This works conda create -y -n test python=3.7 pip numy-base && conda run -n test pip install pytz

This is also affects python 3.7, 3.8, 3.9, 3.10. Python version 3.6 does not have this problem. Switching pip versions does not affect the bug.

We originally though this was a firewall or networking configuration, but after testing it on 3 computers and 3 networks it appears to be replaceable.

Conda Info

active environment : base
    active env location : /home/duncan/miniconda3
            shell level : 1
       user config file : /home/duncan/.condarc
 populated config files :
          conda version : 22.9.0
    conda-build version : not installed
         python version : 3.9.12.final.0
       virtual packages : __linux=4.4.0=0
                          __glibc=2.27=0
                          __unix=0=0
                          __archspec=1=x86_64
       base environment : /home/duncan/miniconda3  (writable)
      conda av data dir : /home/duncan/miniconda3/etc/conda
  conda av metadata url : None
           channel URLs : 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/duncan/miniconda3/pkgs
                          /home/duncan/.conda/pkgs
       envs directories : /home/duncan/miniconda3/envs
                          /home/duncan/.conda/envs
               platform : linux-64
             user-agent : conda/22.9.0 requests/2.28.1 CPython/3.9.12 Linux/4.4.0-19041-Microsoft ubuntu/18.04.2 glibc/2.27
                UID:GID : 1000:1000
             netrc file : None
           offline mode : False

### Conda Config

```shell
(base) duncan@win10:/mnt/c/Users/duncan$ conda config --show-sources

### Conda list

```shell
(base) duncan@win10:/mnt/c/Users/duncan$ conda list --show-channel-urls
# packages in environment at /home/duncan/miniconda3:
#
# Name                    Version                   Build  Channel
_libgcc_mutex             0.1                        main    defaults
_openmp_mutex             5.1                       1_gnu    defaults
brotlipy                  0.7.0           py39h27cfd23_1003    defaults
ca-certificates           2022.10.11           h06a4308_0    defaults
certifi                   2022.9.24        py39h06a4308_0    defaults
cffi                      1.15.1           py39h74dc2b5_0    defaults
charset-normalizer        2.0.4              pyhd3eb1b0_0    defaults
conda                     22.9.0           py39h06a4308_0    defaults
conda-package-handling    1.9.0            py39h5eee18b_1    defaults
cryptography              38.0.1           py39h9ce1e76_0    defaults
idna                      3.4              py39h06a4308_0    defaults
ld_impl_linux-64          2.38                 h1181459_1    defaults
libffi                    3.3                  he6710b0_2    defaults
libgcc-ng                 11.2.0               h1234567_1    defaults
libgomp                   11.2.0               h1234567_1    defaults
libstdcxx-ng              11.2.0               h1234567_1    defaults
ncurses                   6.3                  h5eee18b_3    defaults
openssl                   1.1.1q               h7f8727e_0    defaults
pycosat                   0.6.4            py39h5eee18b_0    defaults
pycparser                 2.21               pyhd3eb1b0_0    defaults
pyopenssl                 22.0.0             pyhd3eb1b0_0    defaults
pysocks                   1.7.1            py39h06a4308_0    defaults
python                    3.9.12               h12debd9_0    defaults
readline                  8.2                  h5eee18b_0    defaults
requests                  2.28.1           py39h06a4308_0    defaults
ruamel_yaml               0.15.100         py39h27cfd23_0    defaults
setuptools                65.5.0           py39h06a4308_0    defaults
sqlite                    3.39.3               h5082296_0    defaults
tk                        8.6.12               h1ccaba5_0    defaults
toolz                     0.11.2             pyhd3eb1b0_0    defaults
tqdm                      4.64.1           py39h06a4308_0    defaults
tzdata                    2022f                h04d1e81_0    defaults
urllib3                   1.26.12          py39h06a4308_0    defaults
xz                        5.2.6                h5eee18b_0    defaults
yaml                      0.2.5                h7b6447c_0    defaults
zlib                      1.2.13               h5eee18b_0    defaults


### Additional Context

Versions of Windows tested: 21H2 22H2
Linux distributions tested: Ubuntu 18.04 Ubuntu 20.04
Only affects WSL 1
pip versions tested: 21.04, 22.04

Tested in a virtual machine running 22H2 as well.
duncanmcbryde commented 2 years ago

Here is the output of pip after trying to install a package without numby-base present broken by NewConnectionError on WSL 1

conda run -n test pip install --no-cache-dir asn1crypto
WARNING: Retrying (Retry(total=4, connect=None, read=None, redirect=None, status=None)) after connection broken by 'NewConnectionError('<pip._vendor.urllib3.connection.HTTPSConnection object at 0x7fb70a269130>: Failed to establish a new connection: [Errno -2] Name or service not known')': /simple/asn1crypto/
WARNING: Retrying (Retry(total=3, connect=None, read=None, redirect=None, status=None)) after connection broken by 'NewConnectionError('<pip._vendor.urllib3.connection.HTTPSConnection object at 0x7fb70a269460>: Failed to establish a new connection: [Errno -2] Name or service not known')': /simple/asn1crypto/
WARNING: Retrying (Retry(total=2, connect=None, read=None, redirect=None, status=None)) after connection broken by 'NewConnectionError('<pip._vendor.urllib3.connection.HTTPSConnection object at 0x7fb70a2696d0>: Failed to establish a new connection: [Errno -2] Name or service not known')': /simple/asn1crypto/
WARNING: Retrying (Retry(total=1, connect=None, read=None, redirect=None, status=None)) after connection broken by 'NewConnectionError('<pip._vendor.urllib3.connection.HTTPSConnection object at 0x7fb70a269880>: Failed to establish a new connection: [Errno -2] Name or service not known')': /simple/asn1crypto/
WARNING: Retrying (Retry(total=0, connect=None, read=None, redirect=None, status=None)) after connection broken by 'NewConnectionError('<pip._vendor.urllib3.connection.HTTPSConnection object at 0x7fb70a269a30>: Failed to establish a new connection: [Errno -2] Name or service not known')': /simple/asn1crypto/
ERROR: Could not find a version that satisfies the requirement asn1crypto (from versions: none)
ERROR: No matching distribution found for asn1crypto
WARNING: There was an error checking the latest version of pip.

While monitoring the connection with Wireshark, no packets are generated. Whith numpy-base present, we can see the packets generated and connections made, and the download succeeds.

travishathaway commented 1 year ago

Hi @duncanmcbryde,

Thank you for reporting this bug. I have just tried this myself on my Windows computer running the WSL and was able to recreate it.

I am not sure when we will be able to look into this further, but we will update this issue when/if we do.

benoitbesson commented 1 year ago

Reproduced today on a recent updated installation:

a7744hsc commented 10 months ago

I encounter similar issue with latest conda and python3.10. Inspired by the issue, a temp solution is run conda install numpy-base before using pip

DenisAraujo68 commented 5 months ago

Almost 2 years after, this bug keep happening (Windows PRO / WSL 1 / Ubuntu 22.04).

StanleyLeiSun commented 3 months ago

To update this thread, upgrade the packages works for me.

sudo apt-get update sudo apt-get upgrade

from: https://stackoverflow.com/questions/59635259/pip-install-generates-warnings-newconnectionerrorpip-vendor-urllib3-conne/68572574