Quantcast
Viewing all articles
Browse latest Browse all 14040

Poetry. Does add install or create a virtual environment?

I am getting very confused trying to understand Poetry usage.

I thought you needed poetry install to actually install packages (after adding them)But I have not run that, and only did

poetry add pytest --devCreating virtualenv rp-poetry-L1ArV34E-py3.9 in /home/myself/.cache/pypoetry/virtualenvsThe --dev option is deprecated, use the `--group dev` notation instead.Using version ^7.4.4 for pytestUpdating dependenciesResolving dependencies... (0.8s)Writing lock filePackage operations: 6 installs, 0 updates, 0 removals• Installing exceptiongroup (1.2.0)• Installing iniconfig (2.0.0)• Installing packaging (23.2)• Installing pluggy (1.3.0)• Installing tomli (2.0.1)• Installing pytest (7.4.4)

With that I get the following strange things:

  • It says that add created a virtual environment! Why???

  • I did ls ~/.cache/pypoetry/virtualenvs/ and there are two! virtual environments (When was the first one created and why poetry env list did not report anything)

  • I did

    poetry env list

    rp-poetry-L1ArV34E-py3.9 (Activated)

so the virtual environment is activated right!?Then why when I do this

python -c 'import pytest'Traceback (most recent call last):  File "<string>", line 1, in <module>ModuleNotFoundError: No module named 'pytest'

but when I do this poetry run python -c 'import pytest' it is OK?

That means that the virtual environment IS NOT activated right?

  • and last, why is pytest being imported without problem if I have not done poetry install

Viewing all articles
Browse latest Browse all 14040

Trending Articles