question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Poetry always updates packages when installed to system python

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).

Issue

In gist link I attached Dockerfile, pyproject.toml and poetry.lock files. Issue is when building docker image I used poetry config virtualenvs.create false to install dependencies to current system python interpreter. It works, but executing poetry install several times always updates some packages, which already installed:

Step 6/7 : RUN poetry install
 ---> Running in 482dd5a533eb
Skipping virtualenv creation, as specified in config file.
Installing dependencies from lock file


Package operations: 0 installs, 13 updates, 0 removals

  - Updating six (1.14.0 /root/.poetry/lib/poetry/_vendor/py3.7 -> 1.14.0)
  - Updating pycparser (2.19 /root/.poetry/lib/poetry/_vendor/py3.7 -> 2.19)
  - Updating webencodings (0.5.1 /root/.poetry/lib/poetry/_vendor/py3.7 -> 0.5.1)
  - Updating zipp (1.1.0 /root/.poetry/lib/poetry/_vendor/py3.7 -> 2.2.0)
  - Updating certifi (2019.11.28 /root/.poetry/lib/poetry/_vendor/py3.7 -> 2019.11.28)
  - Updating cffi (1.13.2 /root/.poetry/lib/poetry/_vendor/py3.7 -> 1.14.0)
  - Updating chardet (3.0.4 /root/.poetry/lib/poetry/_vendor/py3.7 -> 3.0.4)
  - Updating idna (2.8 /root/.poetry/lib/poetry/_vendor/py3.7 -> 2.9)
  - Updating importlib-metadata (1.1.3 /root/.poetry/lib/poetry/_vendor/py3.7 -> 1.5.0)
  - Updating pyparsing (2.4.6 /root/.poetry/lib/poetry/_vendor/py3.7 -> 2.4.6)
  - Updating urllib3 (1.25.8 /root/.poetry/lib/poetry/_vendor/py3.7 -> 1.25.8)
  - Updating attrs (19.3.0 /root/.poetry/lib/poetry/_vendor/py3.7 -> 19.3.0)
  - Updating requests (2.22.0 /root/.poetry/lib/poetry/_vendor/py3.7 -> 2.23.0)
Removing intermediate container 482dd5a533eb
 ---> 925b32fada09
Step 7/7 : RUN poetry install
 ---> Running in e32deef3d215
Skipping virtualenv creation, as specified in config file.
Installing dependencies from lock file


Package operations: 0 installs, 13 updates, 0 removals

  - Updating six (1.14.0 /root/.poetry/lib/poetry/_vendor/py3.7 -> 1.14.0)
  - Updating pycparser (2.19 /root/.poetry/lib/poetry/_vendor/py3.7 -> 2.19)
  - Updating webencodings (0.5.1 /root/.poetry/lib/poetry/_vendor/py3.7 -> 0.5.1)
  - Updating zipp (1.1.0 /root/.poetry/lib/poetry/_vendor/py3.7 -> 2.2.0)
  - Updating certifi (2019.11.28 /root/.poetry/lib/poetry/_vendor/py3.7 -> 2019.11.28)
  - Updating cffi (1.13.2 /root/.poetry/lib/poetry/_vendor/py3.7 -> 1.14.0)
  - Updating chardet (3.0.4 /root/.poetry/lib/poetry/_vendor/py3.7 -> 3.0.4)
  - Updating idna (2.8 /root/.poetry/lib/poetry/_vendor/py3.7 -> 2.9)
  - Updating importlib-metadata (1.1.3 /root/.poetry/lib/poetry/_vendor/py3.7 -> 1.5.0)
  - Updating pyparsing (2.4.6 /root/.poetry/lib/poetry/_vendor/py3.7 -> 2.4.6)
  - Updating urllib3 (1.25.8 /root/.poetry/lib/poetry/_vendor/py3.7 -> 1.25.8)
  - Updating attrs (19.3.0 /root/.poetry/lib/poetry/_vendor/py3.7 -> 19.3.0)
  - Updating requests (2.22.0 /root/.poetry/lib/poetry/_vendor/py3.7 -> 2.23.0)
Removing intermediate container e32deef3d215
 ---> 8b888f67dd60

But if set poetry config virtualenvs.create to default (to true) and create and activate virtualenv, then several poetry install works as expected and exit fast, because all packages already installed:

Installing dependencies from lock file

No dependencies to install or update

Issue Analytics

  • State:closed
  • Created 4 years ago
  • Reactions:10
  • Comments:6 (1 by maintainers)

github_iconTop GitHub Comments

2reactions
HodeiGcommented, Jul 6, 2020

I was experiencing the same issue with poetry 1.0.9.

I managed to narrow down the issue to some old “export PYTHONPATH” in my .bashrc file. After getting rid of that export, the issue went away.

[optional] Debugging steps: Basically, in poetry/repositories/installed_repository.py I noticed that one of the entries ‘/home/hodei/src/my_package’ would fail at https://github.com/python-poetry/poetry/blob/b19873ae4f4391b89bd6fe89aed52963c44db078/poetry/repositories/installed_repository.py#L59:

ValueError: ‘/home/hodei/src/my_package/my_pakcage.egg-info’ does not start with ‘/home/hodei/src/my_package/.venv/src’

Due to the above, all the packages “source_type” were getting marked as “directory” type. Later on, during the installation because of the different “source_type”, at line https://github.com/python-poetry/poetry/blob/b19873ae4f4391b89bd6fe89aed52963c44db078/poetry/puzzle/solver.py#L95, all the packages were getting marked for an update, causing the problem described in this Issue.

Before removing the export, my sys.path was:

$ echo $PYTHONPATH 
/home/hodei/.local/lib/python/site-packages:/home/hodei/local/lib/python2.7/site-packages:
$ cd src/my_package
$ source .venv/bin/activate
$ python -c "import sys; print(sys.path)"
['', '/home/hodei/.local/lib/python/site-packages', '/home/hodei/local/lib/python2.7/site-packages', '/home/hodei/src/my_package', '/home/hodei/.pyenv/versions/3.7.7/lib/python37.zip', '/home/hodei/.pyenv/versions/3.7.7/lib/python3.7', '/home/hodei/.pyenv/versions/3.7.7/lib/python3.7/lib-dynload', '/home/hodei/src/my_package/.venv/lib/python3.7/site-packages']

After removing the export, my sys.path was:

$ unset PYTHONPATH
$ cd src/my_package
$ source .venv/bin/activate
$python -c "import sys; print(sys.path)"
['', '/home/hodei/.pyenv/versions/3.7.7/lib/python37.zip', '/home/hodei/.pyenv/versions/3.7.7/lib/python3.7', '/home/hodei/.pyenv/versions/3.7.7/lib/python3.7/lib-dynload', '/home/hodei/src/my_package/.venv/lib/python3.7/site-packages', '/home/hodei/src/my_package/.venv/src/trading-ig', '/home/hodei/src/my_package']
1reaction
danmurcommented, Mar 3, 2020

I have this problem too, but in my case I’m not using the system Python, it seems to be to do with private repos. I’ll mention it here since the symptom is the same. I fixed it by removing type = "legacy" from all the package references in my poetry.lock since a new project I checked didn’t have the same problem, and it didn’t have that.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Update Packages in Python Poetry - YippeeCode
First step is to find out what packages are currently installed in your system. Then, find the ones that are outdated. You can...
Read more >
Commands | Documentation | Poetry - Python dependency ...
This command will help you kickstart your new Python project by creating a ... By default poetry will install your project's package every...
Read more >
Dependency Management With Python Poetry
A dependency manager like Python Poetry helps you specify, install, and resolve external packages in your projects. This way, you can be sure ......
Read more >
How To Install Poetry to Manage Python Dependencies on ...
Poetry is installed using an official installation script provided on the Poetry website. This command will download the installation script, ...
Read more >
Poetry Advance - Python Biella Group
Poetry is the most sofisticated Python dependency system available (up to 2020) ... installation instructions because they frequently change with new updates ......
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found