Error: Python packaging tool 'setuptools' not found
Asked Answered
D

4

28

I have a poetry project that is not using setuptools

[tool.poetry.dependencies]
python = ">=3.9,<3.11"
opencv-python = "^4.7.0.68"
tensorflow-macos = "^2.11.0"
tensorflow-metal = "^0.7.0"

but I keep getting this error in pycharm. Command from screenshot:

/Users/mc/Library/Caches/pypoetry/virtualenvs/besafe-_8yAv-v6-py3.9/bin/Python /Users/mc/Library/Application Support/JetBrains/Toolbox/apps/PyCharm-P/ch-0/223.8214.51/PyCharm.app/Contents/plugins/python/helpers/packaging_tool.py list

It just pops up without any action from my side. It seems like PyCharm is doing some execution under the hood but I do not know what is it.

I do not understand how am I supposed to fix this?

enter image description here

Dogoodism answered 1/2, 2023 at 9:9 Comment(4)
What's the executed command? -- You should always avoid posting screenshots of text (or code), and copy-paste the text into your question instead.Gayomart
No command is executed it just popup at some times. I think PyCharm is doing sth underneeth but I do not know what.Dogoodism
@Gayomart just added full command to the post. PyCharm is probably doing sth expected but I do not know what ;)Dogoodism
Track the PyCharm issue here: youtrack.jetbrains.com/issue/PY-48909/…Moccasin
T
18

While it seems that this requires a fix from the PyCharm team, an interim solution is to install setuptools as a development dependency,

new version (thanks @milonimrod)

poetry add --group dev setuptools

old version,

poetry add --dev setuptools
Tuning answered 28/4, 2023 at 14:16 Comment(1)
I would recommend using poetry add --group dev setuptools as --dev is deprecated.Albescent
A
2

In my case, the only solution was to uninstall PyCharm and install the newest version. All problems disappeared. The problems started when I began using Python 3.12 instead of Python 3.11. Unfortunately, I don't remember the version of the old PyCharm that made problems.

Adaline answered 5/1 at 22:26 Comment(5)
I am not sure if it's the only solution, but for me it was for sure the quickest. Updating from 3.10 to 3.12 was the trigger for me.Procuration
Thanks. Got that error during Poetry env creation for Python 3.12 installed via pyenv. Upgrading from PyCharm 2023.1.3 to 2023.3.3 solved it.Spiegelman
Not work for me. I've updated my PyCharm CE to 2023.3.5 from 2023.2 but still have the same issue.Gonfanon
@Gonfanon what i recommend is uninstall old version and install new oneAdaline
Worthy to note that as of 3.12, setuptools is no longer installed by default.Civilly
T
0

I followed these steps to solve it using poetry env in PyCharm. I'm writing all the steps assuming the person trying to find the answer has ended up here for a generic 'setuptools' not found failure in PyCharm and doesn't even have Poetry to start with. My current setup is PyCharm 2023.3.6 (Community Edition) on a Mac M3 with Sonoma 14.3.

Steps:

brew install pipx

pipx ensurepath

sudo pipx ensurepath --global
pipx install poetry
  • Go to PyCharm -> Settings -> Project -> Python Interpreter -> Add Interpreter -> New -> Poetry Environment -> OK. This should create a new poetry environment.

  • Inside the newly created Poetry env in PyCharm terminal (make sure to restart the terminal so that the changes can take effect), run this command as mentioned by Russell:

poetry add --group dev setuptools

Once you do this, pip or pip3 should work fine in this environment.

Tabbi answered 21/6 at 5:6 Comment(0)
S
-2

Check if pip is installed and is added to path variable. It seems like pip is missing, Download pip and try again.

Linux:

sudo apt install python3-pip

Follow this documentation for more. https://pip.pypa.io/en/stable/installation/

pip install setuptools
Saylor answered 1/2, 2023 at 9:19 Comment(3)
I'm using poetry not pip. Why I should install pip just to fix this bug? Is Pycharm using it under the hood?Dogoodism
Try install setuptools using pip and check if the error is resolved.Saylor
so hater, he is trying to helpCulosio

© 2022 - 2024 — McMap. All rights reserved.