Help figuring out why my python dependencies are messed up

So I have a repl that is in a weird state that I cannot dig myself out of.

if from the command line I run:

poetry run python main.py

the app starts fine

However, if I click the run button I get:

Replit: Updating package configuration
→ python3 -m poetry lock
/home/runner/fcasanabot/venv/bin/python3: No module named poetry
exit status 1
Replit: Package operation failed.

I am sure poetry is installing dependencies to somewhere other than the venv in my local directory. But I don’t know where it is or how to tell it to use the venv.

Here is my replit.nix file:

{ pkgs }: {
deps = [
pkgs.python39Packages.poetry
pkgs.python39Full
];
env = {
PYTHON_LD_LIBRARY_PATH = pkgs.lib.makeLibraryPath [
# Needed for pandas / numpy
pkgs.stdenv.cc.cc.lib
pkgs.zlib
# Needed for pygame
pkgs.glib
# Needed for matplotlib
pkgs.xorg.libX11
];
PYTHONBIN = “${pkgs.python39Full}/bin/python3.9”;
LANG = “en_US.UTF-8”;
};
}

I do have a venv directory, but this is an interesting output:

~/fcasanabot$ find . -name ‘asana’
./.cache/pypoetry/virtualenvs/asana_listener-T0xMmFYQ-py3.9/lib/python3.9/site-packages/asana

So asana is not installed to that directory.

1 Like

well a few minutes after typing this up, i ran:

~/fcasanabot$ rm -rf .cache/pypoetry/*

and the project seems to work. Perhaps this will help someone in posterity.

Hey @nafeger welcome ot the forums.

Many people have been experiencing bugs with pakages over the past day and a bug report has been made by another community member. Here is a solution:

Needs to be changed for the package you are using

1 Like

Appreciate that quick reply @ethan, however, running pip install poetry was not successful:


~/fcasanabot$ pip install poetry
WARNING: --use-feature=2020-resolver no longer has any effect, since it is now the default dependency resolver in pip. This will become an error in pip 21.0.
WARNING: pip is using lazily downloaded wheels using HTTP range requests to obtain dependency information. This experimental feature is enabled through --use-feature=fast-deps and it is not ready for production.
Looking in indexes: https://package-proxy.replit.com/pypi/simple/
Collecting poetry
  Obtaining dependency information from poetry 1.1.14
ERROR: Exception:
Traceback (most recent call last):
  File "/home/runner/fcasanabot/venv/lib/python3.9/site-packages/pip/_internal/cli/base_command.py", line 180, in _main
    status = self.run(options, args)
  File "/home/runner/fcasanabot/venv/lib/python3.9/site-packages/pip/_internal/cli/req_command.py", line 205, in wrapper
    return func(self, options, args)
  File "/home/runner/fcasanabot/venv/lib/python3.9/site-packages/pip/_internal/commands/install.py", line 318, in run
    requirement_set = resolver.resolve(
  File "/home/runner/fcasanabot/venv/lib/python3.9/site-packages/pip/_internal/resolution/resolvelib/resolver.py", line 127, in resolve
    result = self._result = resolver.resolve(
  File "/home/runner/fcasanabot/venv/lib/python3.9/site-packages/pip/_vendor/resolvelib/resolvers.py", line 473, in resolve
    state = resolution.resolve(requirements, max_rounds=max_rounds)
  File "/home/runner/fcasanabot/venv/lib/python3.9/site-packages/pip/_vendor/resolvelib/resolvers.py", line 341, in resolve
    name, crit = self._merge_into_criterion(r, parent=None)
  File "/home/runner/fcasanabot/venv/lib/python3.9/site-packages/pip/_vendor/resolvelib/resolvers.py", line 172, in _merge_into_criterion
    if not criterion.candidates:
  File "/home/runner/fcasanabot/venv/lib/python3.9/site-packages/pip/_vendor/resolvelib/structs.py", line 139, in __bool__
    return bool(self._sequence)
  File "/home/runner/fcasanabot/venv/lib/python3.9/site-packages/pip/_internal/resolution/resolvelib/found_candidates.py", line 143, in __bool__
    return any(self)
  File "/home/runner/fcasanabot/venv/lib/python3.9/site-packages/pip/_internal/resolution/resolvelib/found_candidates.py", line 129, in <genexpr>
    return (c for c in iterator if id(c) not in self._incompatible_ids)
  File "/home/runner/fcasanabot/venv/lib/python3.9/site-packages/pip/_internal/resolution/resolvelib/found_candidates.py", line 33, in _iter_built
    candidate = func()
  File "/home/runner/fcasanabot/venv/lib/python3.9/site-packages/pip/_internal/resolution/resolvelib/factory.py", line 200, in _make_candidate_from_link
    self._link_candidate_cache[link] = LinkCandidate(
  File "/home/runner/fcasanabot/venv/lib/python3.9/site-packages/pip/_internal/resolution/resolvelib/candidates.py", line 306, in __init__
    super().__init__(
  File "/home/runner/fcasanabot/venv/lib/python3.9/site-packages/pip/_internal/resolution/resolvelib/candidates.py", line 151, in __init__
    self.dist = self._prepare()
  File "/home/runner/fcasanabot/venv/lib/python3.9/site-packages/pip/_internal/resolution/resolvelib/candidates.py", line 234, in _prepare
    dist = self._prepare_distribution()
  File "/home/runner/fcasanabot/venv/lib/python3.9/site-packages/pip/_internal/resolution/resolvelib/candidates.py", line 317, in _prepare_distribution
    return self._factory.preparer.prepare_linked_requirement(
  File "/home/runner/fcasanabot/venv/lib/python3.9/site-packages/pip/_internal/operations/prepare.py", line 502, in prepare_linked_requirement
    wheel_dist = self._fetch_metadata_using_lazy_wheel(link)
  File "/home/runner/fcasanabot/venv/lib/python3.9/site-packages/pip/_internal/operations/prepare.py", line 445, in _fetch_metadata_using_lazy_wheel
    return dist_from_wheel_url(name, url, self._session)
  File "/home/runner/fcasanabot/venv/lib/python3.9/site-packages/pip/_internal/network/lazy_wheel.py", line 32, in dist_from_wheel_url
    with LazyZipOverHTTP(url, session) as wheel:
  File "/home/runner/fcasanabot/venv/lib/python3.9/site-packages/pip/_internal/network/lazy_wheel.py", line 54, in __init__
    assert head.status_code == 200
AssertionError

Like Ethan mentioned, there was a bug a few days ago affecting poetry and I’m not sure if it has been fixed or not.

From your original question, if running poetry run python main.py works fine, then you could configure the .replit file in order to make the Run button work. Just type this into the .replit file:

run="poetry run python main.py"

Also a side note for Nix, once you make a change to the replit.nix file, you might want to type kill 1 into the Shell to update the repl.

Hope this helps!

1 Like