poetry: FileNotFound error when installing packages when console script same name as package for Python 2.7
- I am on the latest Poetry version.
 - I have searched the issues of this repo and believe that this is not a duplicate.
 -  If an exception occurs when executing a command, I executed it again in debug mode (
-vvvoption). 
- OS version and name: Ubuntu 20.04
 - Poetry version: 1.1.3
 - Link of a Gist with the contents of your pyproject.toml file:
 
Issue
If I have a console script with the same name as the package, I get a FileNotFound error when I do poetry install in a python 2.7 virtualenv:
$ poetry init mytest
# Put the pyproject.toml from my gist in the root directory of the package
# Put the main.py from my gist in the mytest directory
$ poetry update
$ poetry env use 2.7
$ poetry install -vvv
Using virtualenv: /home/developer/.cache/pypoetry/virtualenvs/mytest-qD4dPpKx-py2.7
Installing dependencies from lock file
Finding the necessary packages for the current system
Package operations: 0 installs, 18 updates, 0 removals, 1 skipped
  • Removing colorama (0.4.4): Pending...
  • Removing colorama (0.4.4): Skipped for the following reason: Not currently installed
  • Updating contextlib2 (0.6.0.post1 /home/developer/.cache/pypoetry/virtualenvs/mytest-qD4dPpKx-py2.7/lib/python2.7/site-packages -> 0.6.0.post1): Pending...
  • Updating contextlib2 (0.6.0.post1 /home/developer/.cache/pypoetry/virtualenvs/mytest-qD4dPpKx-py2.7/lib/python2.7/site-packages -> 0.6.0.post1): Installing...
  • Updating contextlib2 (0.6.0.post1 /home/developer/.cache/pypoetry/virtualenvs/mytest-qD4dPpKx-py2.7/lib/python2.7/site-packages -> 0.6.0.post1)
  • Updating scandir (1.10.0 /home/developer/.cache/pypoetry/virtualenvs/mytest-qD4dPpKx-py2.7/lib/python2.7/site-packages -> 1.10.0): Pending...
  • Updating scandir (1.10.0 /home/developer/.cache/pypoetry/virtualenvs/mytest-qD4dPpKx-py2.7/lib/python2.7/site-packages -> 1.10.0): Installing...
  • Updating scandir (1.10.0 /home/developer/.cache/pypoetry/virtualenvs/mytest-qD4dPpKx-py2.7/lib/python2.7/site-packages -> 1.10.0)
  • Updating six (1.15.0 /home/developer/.cache/pypoetry/virtualenvs/mytest-qD4dPpKx-py2.7/lib/python2.7/site-packages -> 1.15.0): Pending...
  • Updating six (1.15.0 /home/developer/.cache/pypoetry/virtualenvs/mytest-qD4dPpKx-py2.7/lib/python2.7/site-packages -> 1.15.0): Installing...
  • Updating six (1.15.0 /home/developer/.cache/pypoetry/virtualenvs/mytest-qD4dPpKx-py2.7/lib/python2.7/site-packages -> 1.15.0)
  • Updating configparser (4.0.2 /home/developer/.cache/pypoetry/virtualenvs/mytest-qD4dPpKx-py2.7/lib/python2.7/site-packages -> 4.0.2): Pending...
  • Updating configparser (4.0.2 /home/developer/.cache/pypoetry/virtualenvs/mytest-qD4dPpKx-py2.7/lib/python2.7/site-packages -> 4.0.2): Installing...
  • Updating configparser (4.0.2 /home/developer/.cache/pypoetry/virtualenvs/mytest-qD4dPpKx-py2.7/lib/python2.7/site-packages -> 4.0.2)
  • Updating pathlib2 (2.3.5 /home/developer/.cache/pypoetry/virtualenvs/mytest-qD4dPpKx-py2.7/lib/python2.7/site-packages -> 2.3.5): Pending...
  • Updating pathlib2 (2.3.5 /home/developer/.cache/pypoetry/virtualenvs/mytest-qD4dPpKx-py2.7/lib/python2.7/site-packages -> 2.3.5): Installing...
  • Updating pathlib2 (2.3.5 /home/developer/.cache/pypoetry/virtualenvs/mytest-qD4dPpKx-py2.7/lib/python2.7/site-packages -> 2.3.5)
  • Updating zipp (1.2.0 /home/developer/.cache/pypoetry/virtualenvs/mytest-qD4dPpKx-py2.7/lib/python2.7/site-packages -> 1.2.0): Pending...
  • Updating zipp (1.2.0 /home/developer/.cache/pypoetry/virtualenvs/mytest-qD4dPpKx-py2.7/lib/python2.7/site-packages -> 1.2.0): Installing...
  • Updating zipp (1.2.0 /home/developer/.cache/pypoetry/virtualenvs/mytest-qD4dPpKx-py2.7/lib/python2.7/site-packages -> 1.2.0)
  • Updating backports.functools-lru-cache (1.6.1 /home/developer/.cache/pypoetry/virtualenvs/mytest-qD4dPpKx-py2.7/lib/python2.7/site-packages -> 1.6.1): Pending...
  • Updating backports.functools-lru-cache (1.6.1 /home/developer/.cache/pypoetry/virtualenvs/mytest-qD4dPpKx-py2.7/lib/python2.7/site-packages -> 1.6.1): Installing...
  • Updating backports.functools-lru-cache (1.6.1 /home/developer/.cache/pypoetry/virtualenvs/mytest-qD4dPpKx-py2.7/lib/python2.7/site-packages -> 1.6.1)
  • Updating importlib-metadata (2.0.0 /home/developer/.cache/pypoetry/virtualenvs/mytest-qD4dPpKx-py2.7/lib/python2.7/site-packages -> 2.0.0): Pending...
  • Updating importlib-metadata (2.0.0 /home/developer/.cache/pypoetry/virtualenvs/mytest-qD4dPpKx-py2.7/lib/python2.7/site-packages -> 2.0.0): Installing...
  • Updating importlib-metadata (2.0.0 /home/developer/.cache/pypoetry/virtualenvs/mytest-qD4dPpKx-py2.7/lib/python2.7/site-packages -> 2.0.0)
  • Updating pyparsing (2.4.7 /home/developer/.cache/pypoetry/virtualenvs/mytest-qD4dPpKx-py2.7/lib/python2.7/site-packages -> 2.4.7): Pending...
  • Updating pyparsing (2.4.7 /home/developer/.cache/pypoetry/virtualenvs/mytest-qD4dPpKx-py2.7/lib/python2.7/site-packages -> 2.4.7): Installing...
  • Updating pyparsing (2.4.7 /home/developer/.cache/pypoetry/virtualenvs/mytest-qD4dPpKx-py2.7/lib/python2.7/site-packages -> 2.4.7)
  • Updating atomicwrites (1.4.0 /home/developer/.cache/pypoetry/virtualenvs/mytest-qD4dPpKx-py2.7/lib/python2.7/site-packages -> 1.4.0): Pending...
  • Updating atomicwrites (1.4.0 /home/developer/.cache/pypoetry/virtualenvs/mytest-qD4dPpKx-py2.7/lib/python2.7/site-packages -> 1.4.0): Installing...
  • Updating attrs (20.2.0 /home/developer/.cache/pypoetry/virtualenvs/mytest-qD4dPpKx-py2.7/lib/python2.7/site-packages -> 20.2.0): Pending...
  • Updating attrs (20.2.0 /home/developer/.cache/pypoetry/virtualenvs/mytest-qD4dPpKx-py2.7/lib/python2.7/site-packages -> 20.2.0): Installing...
  • Updating atomicwrites (1.4.0 /home/developer/.cache/pypoetry/virtualenvs/mytest-qD4dPpKx-py2.7/lib/python2.7/site-packages -> 1.4.0)
  • Updating attrs (20.2.0 /home/developer/.cache/pypoetry/virtualenvs/mytest-qD4dPpKx-py2.7/lib/python2.7/site-packages -> 20.2.0): Pending...
  • Updating attrs (20.2.0 /home/developer/.cache/pypoetry/virtualenvs/mytest-qD4dPpKx-py2.7/lib/python2.7/site-packages -> 20.2.0): Installing...
  • Updating funcsigs (1.0.2 /home/developer/.cache/pypoetry/virtualenvs/mytest-qD4dPpKx-py2.7/lib/python2.7/site-packages -> 1.0.2): Pending...
  • Updating funcsigs (1.0.2 /home/developer/.cache/pypoetry/virtualenvs/mytest-qD4dPpKx-py2.7/lib/python2.7/site-packages -> 1.0.2): Installing...
  • Updating funcsigs (1.0.2 /home/developer/.cache/pypoetry/virtualenvs/mytest-qD4dPpKx-py2.7/lib/python2.7/site-packages -> 1.0.2)
  • Updating attrs (20.2.0 /home/developer/.cache/pypoetry/virtualenvs/mytest-qD4dPpKx-py2.7/lib/python2.7/site-packages -> 20.2.0)
  • Updating funcsigs (1.0.2 /home/developer/.cache/pypoetry/virtualenvs/mytest-qD4dPpKx-py2.7/lib/python2.7/site-packages -> 1.0.2): Pending...
  • Updating funcsigs (1.0.2 /home/developer/.cache/pypoetry/virtualenvs/mytest-qD4dPpKx-py2.7/lib/python2.7/site-packages -> 1.0.2): Installing...
  • Updating funcsigs (1.0.2 /home/developer/.cache/pypoetry/virtualenvs/mytest-qD4dPpKx-py2.7/lib/python2.7/site-packages -> 1.0.2)
  • Updating more-itertools (5.0.0 /home/developer/.cache/pypoetry/virtualenvs/mytest-qD4dPpKx-py2.7/lib/python2.7/site-packages -> 5.0.0): Pending...
  • Updating more-itertools (5.0.0 /home/developer/.cache/pypoetry/virtualenvs/mytest-qD4dPpKx-py2.7/lib/python2.7/site-packages -> 5.0.0): Installing...
  • Updating more-itertools (5.0.0 /home/developer/.cache/pypoetry/virtualenvs/mytest-qD4dPpKx-py2.7/lib/python2.7/site-packages -> 5.0.0)
  • Updating packaging (20.4 /home/developer/.cache/pypoetry/virtualenvs/mytest-qD4dPpKx-py2.7/lib/python2.7/site-packages -> 20.4): Pending...
  • Updating packaging (20.4 /home/developer/.cache/pypoetry/virtualenvs/mytest-qD4dPpKx-py2.7/lib/python2.7/site-packages -> 20.4): Installing...
  • Updating packaging (20.4 /home/developer/.cache/pypoetry/virtualenvs/mytest-qD4dPpKx-py2.7/lib/python2.7/site-packages -> 20.4)
  • Updating pluggy (0.13.1 /home/developer/.cache/pypoetry/virtualenvs/mytest-qD4dPpKx-py2.7/lib/python2.7/site-packages -> 0.13.1): Pending...
  • Updating pluggy (0.13.1 /home/developer/.cache/pypoetry/virtualenvs/mytest-qD4dPpKx-py2.7/lib/python2.7/site-packages -> 0.13.1): Installing...
  • Updating pluggy (0.13.1 /home/developer/.cache/pypoetry/virtualenvs/mytest-qD4dPpKx-py2.7/lib/python2.7/site-packages -> 0.13.1)
  • Updating py (1.9.0 /home/developer/.cache/pypoetry/virtualenvs/mytest-qD4dPpKx-py2.7/lib/python2.7/site-packages -> 1.9.0): Pending...
  • Updating py (1.9.0 /home/developer/.cache/pypoetry/virtualenvs/mytest-qD4dPpKx-py2.7/lib/python2.7/site-packages -> 1.9.0): Installing...
  • Updating py (1.9.0 /home/developer/.cache/pypoetry/virtualenvs/mytest-qD4dPpKx-py2.7/lib/python2.7/site-packages -> 1.9.0)
  • Updating wcwidth (0.2.5 /home/developer/.cache/pypoetry/virtualenvs/mytest-qD4dPpKx-py2.7/lib/python2.7/site-packages -> 0.2.5): Pending...
  • Updating wcwidth (0.2.5 /home/developer/.cache/pypoetry/virtualenvs/mytest-qD4dPpKx-py2.7/lib/python2.7/site-packages -> 0.2.5): Installing...
  • Updating wcwidth (0.2.5 /home/developer/.cache/pypoetry/virtualenvs/mytest-qD4dPpKx-py2.7/lib/python2.7/site-packages -> 0.2.5)
  • Updating pytest (4.6.11 /home/developer/.cache/pypoetry/virtualenvs/mytest-qD4dPpKx-py2.7/lib/python2.7/site-packages -> 4.6.11): Pending...
  • Updating pytest (4.6.11 /home/developer/.cache/pypoetry/virtualenvs/mytest-qD4dPpKx-py2.7/lib/python2.7/site-packages -> 4.6.11): Installing...
  • Updating pytest (4.6.11 /home/developer/.cache/pypoetry/virtualenvs/mytest-qD4dPpKx-py2.7/lib/python2.7/site-packages -> 4.6.11)
Installing the current project: mytest (0.1.0)
  - Building package mytest in editable mode
  - Adding mytest.pth to /home/developer/.cache/pypoetry/virtualenvs/mytest-qD4dPpKx-py2.7/local/lib/python2.7/dist-packages for /home/developer/projects/poetry/mytest
  - Adding the mytest script to /home/developer/.cache/pypoetry/virtualenvs/mytest-qD4dPpKx-py2.7/local/bin
  Stack trace:
  8  ~/virtualenvs/poetry_1.1.x/lib/python3.7/site-packages/clikit/console_application.py:131 in run
      129│             parsed_args = resolved_command.args
      130│ 
    → 131│             status_code = command.handle(parsed_args, io)
      132│         except KeyboardInterrupt:
      133│             status_code = 1
  7  ~/virtualenvs/poetry_1.1.x/lib/python3.7/site-packages/clikit/api/command/command.py:120 in handle
      118│     def handle(self, args, io):  # type: (Args, IO) -> int
      119│         try:
    → 120│             status_code = self._do_handle(args, io)
      121│         except KeyboardInterrupt:
      122│             if io.is_debug():
  6  ~/virtualenvs/poetry_1.1.x/lib/python3.7/site-packages/clikit/api/command/command.py:171 in _do_handle
      169│         handler_method = self._config.handler_method
      170│ 
    → 171│         return getattr(handler, handler_method)(args, io, self)
      172│ 
      173│     def __repr__(self):  # type: () -> str
  5  ~/virtualenvs/poetry_1.1.x/lib/python3.7/site-packages/cleo/commands/command.py:92 in wrap_handle
       90│         self._command = command
       91│ 
    →  92│         return self.handle()
       93│ 
       94│     def handle(self):  # type: () -> Optional[int]
  4  ~/virtualenvs/poetry_1.1.x/lib/python3.7/site-packages/poetry/console/commands/install.py:105 in handle
      103│             return 0
      104│ 
    → 105│         builder.build()
      106│ 
      107│         if self._io.supports_ansi() and not self.io.is_debug():
  3  ~/virtualenvs/poetry_1.1.x/lib/python3.7/site-packages/poetry/masonry/builders/editable.py:57 in build
       55│         added_files = []
       56│         added_files += self._add_pth()
    →  57│         added_files += self._add_scripts()
       58│         self._add_dist_info(added_files)
       59│ 
  2  ~/virtualenvs/poetry_1.1.x/lib/python3.7/site-packages/poetry/masonry/builders/editable.py:150 in _add_scripts
      148│                 )
      149│             )
    → 150│             with script_file.open("w", encoding="utf-8") as f:
      151│                 f.write(
      152│                     decode(
  1  /usr/lib/python3.7/pathlib.py:1208 in open
      1206│             self._raise_closed()
      1207│         return io.open(self, mode, buffering, encoding, errors, newline,
    → 1208│                        opener=self._opener)
      1209│ 
      1210│     def read_bytes(self):
  FileNotFoundError
  [Errno 2] No such file or directory: '/home/developer/.cache/pypoetry/virtualenvs/mytest-qD4dPpKx-py2.7/local/bin/mytest'
  at /usr/lib/python3.7/pathlib.py:1063 in _opener
      1059│         raise ValueError("I/O operation on closed path")
      1060│ 
      1061│     def _opener(self, name, flags, mode=0o666):
      1062│         # A stub for the opener argument to built-in open()
    → 1063│         return self._accessor.open(self, flags, mode)
      1064│ 
      1065│     def _raw_open(self, flags, mode=0o777):
      1066│         
      1067│         Open the file pointed by this path and return a file descriptor,
This doesn’t happen in python 3.7:
$ poetry env use 3.7
$ poetry install
Installing dependencies from lock file
Package operations: 12 installs, 0 updates, 0 removals
  • Installing zipp (1.2.0)
  • Installing importlib-metadata (2.0.0)
  • Installing pyparsing (2.4.7)
  • Installing six (1.15.0)
  • Installing atomicwrites (1.4.0)
  • Installing attrs (20.2.0)
  • Installing more-itertools (5.0.0)
  • Installing packaging (20.4)
  • Installing pluggy (0.13.1)
  • Installing py (1.9.0)
  • Installing wcwidth (0.2.5)
  • Installing pytest (4.6.11)
Installing the current project: mytest (0.1.0)
About this issue
- Original URL
 - State: closed
 - Created 4 years ago
 - Comments: 15 (2 by maintainers)
 
We’ve decided not to try to fix this in poetry. Instead, we have modified our build system to create the necessary
sysconfigdirectories before invokingpoetry install. That seems to work.@sinoroc Thanks for your feedback. I’ll have to discuss this with my colleagues and see how to proceed.