-vvv option).poetry throws exception if theres a module in cwd conflicting with a stdlib one
to reproduce:
mkdir test && cd test
poetry init -n -q
touch json.py # or {sys,os,platform,select}.py
poetry add requests # or any poetry command
On Poetry 0.12.5 it raises:
[EnvCommandError]
Command /home/me/.cache/pypoetry/virtualenvs/test-py3.6/bin/python -c "im
port json; import os; import platform; import sys; implementation = getattr(sys, 'imple
mentation', None); iver = '{0.major}.{0.minor}.{0.micro}'.format(implementation.version
) if implementation else '0'; implementation_name = implementation.name if implementati
on else ''; env = {'implementation_name': implementation_name,'implementation_version':
iver,'os_name': os.name,'platform_machine': platform.machine(),'platform_release': pla
tform.release(),'platform_system': platform.system(),'platform_version': platform.versi
on(),'python_full_version': platform.python_version(),'platform_python_implementation':
platform.python_implementation(),'python_version': platform.python_version()[:3],'sys_
platform': sys.platform,'version_info': sys.version_info[:3],};print(json.dumps(env))"
errored with the following output:
Traceback (most recent call last):
File "<string>", line 1, in <module>
AttributeError: module 'json' has no attribute 'dumps'
On 0.12.10:
[JSONDecodeError]
Expecting value: line 1 column 1 (char 0)
I can see the error comes from executing python -c, copying the command directly on bash, it does raises an exception but adding the -I : isolate Python from the user's environment (implies -E and -s) flag produces the right output.
Although naming top level modules with stdlib names is not best-practice, some names may not be immediately obvious (I was using select.py), and the error output on current poetry version is not helpful (even with -vvv, took me a while to pin down the error)
I bumped into a similar error with poetry 0.12.11 on mac os with homebrewed python 3.7
I managed to bypass it by erasing the entire the entire ~/Library/Caches/pypoetry folder and everything in it
The solution naringas told worked for me on macOS. Thanks.
I have the same issue on Windows 10. I tried deleting ~/AppData/pypoetry/Cache and is not working.
Here #654 is the same issue with the same solution but nothing works for me.
I have the same issue on Windows 10. I tried deleting ~/AppData/pypoetry/Cache and is not working.
Here #654 is the same issue with the same solution but nothing works for me.
maybe try deleting all of ~/AppData/pypoetry/ ?
This name-shadowing issue is a common stumbling block in Python, not specific to Poetry.
This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.
I agree with @jtrakk. If python will find a module in the current working directory it will prefer it. So there is nothing poetry can do about it here.
Most helpful comment
I bumped into a similar error with poetry 0.12.11 on mac os with homebrewed python 3.7
I managed to bypass it by erasing the entire the entire
~/Library/Caches/pypoetryfolder and everything in it