FileNotFound error when installing packages when console script same name as package for Python 2.7
See original GitHub issue- 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 (
-vvv
option).
- 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)
Issue Analytics
- State:
- Created 3 years ago
- Comments:14 (2 by maintainers)
Top Results From Across the Web
Python - Module Not Found
All modules in Python have to have a certain directory structure. You can find details here. Create an empty file called __init__.py underΒ ......
Read more >Installing Packages - Python Packaging User Guide - Python.org
This section covers the basics of how to install Python packages. It's important to note that the term βpackageβ in this context is...
Read more >Making a Python Package
A βpackageβ is essentially a module, except it can have other modules (and indeed other packages) inside it. A package usually corresponds to...
Read more >Package installation issues | PyCharm Documentation
You might encounter a problem when installing a Python package in the project settings or in ... source <venv path>/bin/activate pip install <package...
Read more >Python FileNotFoundError: [Errno 2] No such file or ...
To fix this error, check that you are referring to the right file or folder in your program.
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Weβve decided not to try to fix this in poetry. Instead, we have modified our build system to create the necessary
sysconfig
directories 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.