[PYTHON] ModuleNotFoundError in poetry: No module named'setuptools'

0. Introduction

I haven't investigated the cause in detail, but a memo of the solution.

1. Environment

2. Phenomenon

I got the following error when installing a git repo with poetry. Name it a repo named hoge.

(.venv) bash-3.2$ poetry update
Updating dependencies
Resolving dependencies... (10.2s)

Writing lock file


Package operations: 12 installs, 0 updates, 0 removals

  - Installing hoge (0.0.1 acd565a)

[EnvCommandError]
Command ['/Users/kazeto/Works/aaa/.venv/bin/pip', 'install', '--no-deps', '-U', '-e', '/Users/kazeto/Works/aaa/.venv/src/hoge'] errored with the following return code 1, and output: 
Obtaining file:///Users/kazeto/Works/aaa/.venv/src/hoge
  Installing build dependencies: started
  Installing build dependencies: finished with status 'done'
  Getting requirements to build wheel: started
  Getting requirements to build wheel: finished with status 'done'
    Preparing wheel metadata: started
    Preparing wheel metadata: finished with status 'done'
Installing collected packages: hoge
  Running setup.py develop for hoge
    ERROR: Command errored out with exit status 1:
     command: /Users/kazeto/Works/aaa/.venv/bin/python -c 'import sys, setuptools, tokenize; sys.argv[0] = '"'"'/Users/kazeto/Works/aaa/.venv/src/hoge/setup.py'"'"'; __file__='"'"'/Users/kazeto/Works/aaa/.venv/src/hoge/setup.py'"'"';f=getattr(tokenize, '"'"'open'"'"', open)(__file__);code=f.read().replace('"'"'\r\n'"'"', '"'"'\n'"'"');f.close();exec(compile(code, __file__, '"'"'exec'"'"'))' develop --no-deps
         cwd: /Users/kazeto/Works/aaa/.venv/src/hoge/
    Complete output (3 lines):
    Traceback (most recent call last):
      File "<string>", line 1, in <module>
    ModuleNotFoundError: No module named 'setuptools'
    ----------------------------------------
ERROR: Command errored out with exit status 1: /Users/kazeto/Works/aaa/.venv/bin/python -c 'import sys, setuptools, tokenize; sys.argv[0] = '"'"'/Users/kazeto/Works/aaa/.venv/src/hoge/setup.py'"'"'; __file__='"'"'/Users/kazeto/Works/aaa/.venv/src/hoge/setup.py'"'"';f=getattr(tokenize, '"'"'open'"'"', open)(__file__);code=f.read().replace('"'"'\r\n'"'"', '"'"'\n'"'"');f.close();exec(compile(code, __file__, '"'"'exec'"'"'))' develop --no-deps Check the logs for full command output.

By the way, as shown in the error log, when I tried to check the log and executed the code that caused the error by hand, it entered normally and I did not understand the cause well ...

(.venv) bash-3.2$ /Users/kazeto/Works/aaa/.venv/bin/python -c 'import sys, setuptools, tokenize; sys.argv[0] = '"'"'/Users/kazeto/Works/aaa/.venv/src/hoge/setup.py'"'"'; __file__='"'"'/Users/kazeto/Works/aaa/.venv/src/hoge/setup.py'"'"';f=getattr(tokenize, '"'"'open'"'"', open)(_le__);code=f.read().replace('"'"'\r\n'"'"', '"'"'\n'"'"');f.close();exec(compile(code, __file__, '"'"'exec'"'"'))' develop --no-deps
running develop
running egg_info
creating hoge.egg-info
writing hoge.egg-info/PKG-INFO
writing dependency_links to hoge.egg-info/dependency_links.txt
writing top-level names to hoge.egg-info/top_level.txt
writing manifest file 'hoge.egg-info/SOURCES.txt'
reading manifest file 'hoge.egg-info/SOURCES.txt'
writing manifest file 'hoge.egg-info/SOURCES.txt'
running build_ext
Creating /Users/kazeto/Works/aaa/.venv/lib/python3.7/site-packages/hoge.egg-link (link to .)
Adding hoge 0.0.1 to easy-install.pth file

Installed 

And when I looked in .venv, setuptools was included.

3. Solution

For the time being, install it by adding setuptools to build-system with pyproject.toml of git repo (hoge in this case).

Before correction

[build-system]
requires = ["poetry>=1.00"]
build-backend = "poetry.masonry.api"

Revised

[build-system]
requires = ["poetry>=1.00", "setuptools"]
build-backend = "poetry.masonry.api"

Postscript

I found an issue now. The version of poetry is different, but this is probably it. https://github.com/python-poetry/poetry/issues/3001

Recommended Posts

ModuleNotFoundError in poetry: No module named'setuptools'
ModuleNotFoundError in Python: No module named story
ModuleNotFoundError: No module named'py4j'
ModuleNotFoundError: No module named'flask_sqlalchemy'
ModuleNotFoundError: No module named'_bz2' error in pyenv Python
Import cv2 ModuleNotFoundError: No module named'cv2' in python3
[Python] ModuleNotFoundError: No module named'urlparse'
Python error: ModuleNotFoundError: No module named'flask'
[Question] No module named'Selenium' in PyCharm
How to resolve ModuleNotFoundError: No module named XXX in Jupyter Notebook
Why ModuleNotFoundError: No module named'dataset.mnist' appears in "Deep Learning from scratch".
What to do when ModuleNotFoundError: No module named'XXX' occurs in Python
Today's python error: ModuleNotFoundError: No module named
Today's python error: ModuleNotFoundError: No module named
Microsoft Cognitive Toolkit: ModuleNotFoundError: No module named'cntk._cntk_py'
ModuleNotFoundError: No module named'***' when running Flask
Today's python error: ModuleNotFoundError: No module named'requests'
Today's python error: ModuleNotFoundError: No module named'bs4'
Import Error in Python3: No module named'xxxxx'
ModuleNotFoundError: No module What to do if you get'tensorflow.contrib'
Resolve No module named tkinter
Solver Problem Error in poetry
I get "sanity check" and "No module" errors in import numpy
Error when installing opencv-python on jetson nano (ModuleNotFoundError: No module named'skbuild')