# Renku CLI - UserWarning: Distutils was imported before Setuptools

**URL:** <https://renku.discourse.group/t/renku-cli-userwarning-distutils-was-imported-before-setuptools/955>\
**Category:** Renku (CLI)\
**Created:** [16 November 2023 15:26 UTC](https://renku.discourse.group/t/renku-cli-userwarning-distutils-was-imported-before-setuptools/955 "2023-11-16T15:26:04Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![champost](https://yyz2.discourse-cdn.com/free1/user_avatar/renku.discourse.group/champost/32/232_2.png) [@champost](https://renku.discourse.group/u/champost)\
**Post date:** [16 November 2023 15:26 UTC](https://renku.discourse.group/t/renku-cli-userwarning-distutils-was-imported-before-setuptools/955/1 "2023-11-16T15:26:04Z")

</div>

Hello,

I reported a warning (see below) thrown by the Renku CLI while working on WSL for Windows : [UserWarning: Distutils was imported before Setuptools · Issue #3650 · SwissDataScienceCenter/renku-python · GitHub](https://github.com/SwissDataScienceCenter/renku-python/issues/3650)

I can now confirm that it also shows up on Linux Mint 21.2 but I am not sure whether I have reported this correctly…

```auto
$ renku --version
/home/champost/.local/pipx/shared/lib/python3.10/site-packages/_distutils_hack/ __init__.py:18: UserWarning: Distutils was imported before Setuptools, but importing Setuptools also replaces the `distutils` module in `sys.modules`. This may lead to undesirable behaviors or errors. To avoid these issues, avoid using distutils directly, ensure that setuptools is installed in the traditional way (e.g. not an editable install), and/or make sure that setuptools is always imported before distutils.
  warnings.warn(
/home/champost/.local/pipx/shared/lib/python3.10/site-packages/_distutils_hack/ __init__.py:33: UserWarning: Setuptools is replacing distutils.
  warnings.warn("Setuptools is replacing distutils.")
2.7.0
$ 

```

Thanks

---

<div class="post-metadata">

**Author:** ![elisabetc](https://yyz2.discourse-cdn.com/free1/user_avatar/renku.discourse.group/elisabetc/32/811_2.png) [@elisabetc](https://renku.discourse.group/u/elisabetc)\
**Post date:** [21 November 2023 10:06 UTC](https://renku.discourse.group/t/renku-cli-userwarning-distutils-was-imported-before-setuptools/955/2 "2023-11-21T10:06:02Z")

</div>

Thank you @champost for reporting this warning.

---

<div class="post-metadata">

**Author:** ![rrrrrok](https://yyz2.discourse-cdn.com/free1/user_avatar/renku.discourse.group/rrrrrok/32/117_2.png) [@rrrrrok](https://renku.discourse.group/u/rrrrrok)\
**Post date:** [28 November 2023 14:53 UTC](https://renku.discourse.group/t/renku-cli-userwarning-distutils-was-imported-before-setuptools/955/3 "2023-11-28T14:53:29Z")

</div>

Hey @champost, I just got fed up with this enough myself to resort to extreme measures ⚒

Based on internet searches, this should be moot in recent versions of setuptools. So I simply deleted the `_distutils_hack` and `distutils-precedence.pth` from the `site-packages` directory. So far so good, though ymmv! My best guess is that those are left behind from some older version of setuptools and are not removed when setuptools is updated.

---

<div class="post-metadata">

**Author:** ![champost](https://yyz2.discourse-cdn.com/free1/user_avatar/renku.discourse.group/champost/32/232_2.png) [@champost](https://renku.discourse.group/u/champost)\
**Post date:** [28 November 2023 16:16 UTC](https://renku.discourse.group/t/renku-cli-userwarning-distutils-was-imported-before-setuptools/955/4 "2023-11-28T16:16:39Z")

</div>

Thanks for the heads up @rrrrrok. Looks like MMDV (My Mileage Does Vary) !

```auto
$ rm -rf /home/champost/.local/lib/python3.10/site-packages/distutils-precedence.pth /home/champost/.local/lib/python3.10/site-packages/_distutils_hack/*

```

```auto
$ renku session ls
/home/champost/.local/pipx/shared/lib/python3.10/site-packages/_distutils_hack/ __init__.py:18: UserWarning: Distutils was imported before Setuptools, but importing Setuptools also replaces the `distutils` module in `sys.modules`. This may lead to undesirable behaviors or errors. To avoid these issues, avoid using distutils directly, ensure that setuptools is installed in the traditional way (e.g. not an editable install), and/or make sure that setuptools is always imported before distutils.
  warnings.warn(
/home/champost/.local/pipx/shared/lib/python3.10/site-packages/_distutils_hack/ __init__.py:33: UserWarning: Setuptools is replacing distutils.
  warnings.warn("Setuptools is replacing distutils.")

Warning: Cannot get sessions list from 'renkulab': Please run the renku login command to authenticate with Renku.

```

---

<div class="post-metadata">

**Author:** ![rrrrrok](https://yyz2.discourse-cdn.com/free1/user_avatar/renku.discourse.group/rrrrrok/32/117_2.png) [@rrrrrok](https://renku.discourse.group/u/rrrrrok)\
**Post date:** [29 November 2023 08:33 UTC](https://renku.discourse.group/t/renku-cli-userwarning-distutils-was-imported-before-setuptools/955/5 "2023-11-29T08:33:04Z")

</div>

Hi @champost,

A few things:

1. from the above, it looks like you removed those packages from the wrong path? i.e. not `~/.local/pipx/shared/lib` but `~/.local/lib`

2. I believe I had to reinstall renku and potentially also restart my terminal. 🤷‍♂️

3. Did you upgrade the version of setuptools first? I did `pipx upgrade-all` which also updates the shared libraries.

---

<div class="post-metadata">

**Author:** ![champost](https://yyz2.discourse-cdn.com/free1/user_avatar/renku.discourse.group/champost/32/232_2.png) [@champost](https://renku.discourse.group/u/champost)\
**Post date:** [29 November 2023 16:37 UTC](https://renku.discourse.group/t/renku-cli-userwarning-distutils-was-imported-before-setuptools/955/6 "2023-11-29T16:37:50Z")

</div>

Hi @rrrrrok ,

I ran `pip install --upgrade setuptools` as mentioned here : [UserWarning: Distutils was imported before Setuptools · Issue #3650 · SwissDataScienceCenter/renku-python · GitHub](https://github.com/SwissDataScienceCenter/renku-python/issues/3650) and now I am a little lost as to what should be my next step… 🤔

Would it be possible to update the [CLI installation problems](https://renku.readthedocs.io/en/latest/how-to-guides/own_machine/cli-installation.html#cli-troubleshooting) section on [https://renku.readthedocs.io](https://renku.readthedocs.io) ? I can then try afresh on a \*nix system and see whether I can reproduce warning or not.

Thanks !

---

<div class="post-metadata">

**Author:** ![rrrrrok](https://yyz2.discourse-cdn.com/free1/user_avatar/renku.discourse.group/rrrrrok/32/117_2.png) [@rrrrrok](https://renku.discourse.group/u/rrrrrok)\
**Post date:** [29 November 2023 18:22 UTC](https://renku.discourse.group/t/renku-cli-userwarning-distutils-was-imported-before-setuptools/955/7 "2023-11-29T18:22:12Z")

</div>

As mentioned in the issue you linked, `pipx` has its own installation of libraries. So a simple `pip install` will not upgrade those libraries. You should do `~/.local/pipx/shared/bin/pip install -U setuptools`. Afterwards _make sure_ you also remove the no longer needed `~/.local/lib/.../site-packages/_distutils_hack` and `~/.local/lib/.../site-packages/distutils-precedence.pth`
