2π
It seems that you have manually created a virtual env in the project directory by e.g. python -m venv venv
. So now you have one in /home/tesla/Documents/projects/graphql/graphenee/venv/
.
After that you added some packages with poetry. However, by default poetry will only look for .venv
directory (note the starting dot) in the project directory. Since poetry did not find a .venv
, it created a new virtual env in /home/tesla/.cache/pypoetry/virtualenvs/graphenee-CXeG5cZ_-py3.9
and installed the packages you added via poetry add
there.
The problem is that you try to use the "empty" virtual env in the project directory instead of the one created by poetry. Fortunately with poetry it is very easy to run command, even without activating the venv, just use poetry run
in the project directory.
To check Django installation:
poetry run python
# Executes: /home/tesla/.cache/pypoetry/virtualenvs/graphenee-CXeG5cZ_-py3.9/bin/python
>>> import django
To run Django management commands:
poetry run ./manage.py startapp users apps/users
It will use the virtual env in /home/tesla/.cache/pypoetry/virtualenvs/graphenee-CXeG5cZ_-py3.9
. You can delete venv
in the project directory.
Note: if you rather want to use a virtual env in the project directory, then delete /home/tesla/.cache/pypoetry/virtualenvs/graphenee-CXeG5cZ_-py3.9
, then create one in the project directory by
python -m venv .venv`
After that install packages with poetry:
poetry install
Now poetry will use the local virtual env in /home/tesla/Documents/projects/graphql/graphenee/.venv
when you run a command via poetry run [cmd]
.
0π
I also had this issue when my project name was django. The name of the poetry virtual env was then also django, and when I ran poetry add django, nothing happened. When I renamed the project the issue was resolved.
- [Answered ]-Django: cannot import settings, cannot login to admin, cannot change admin password
- [Answered ]-How to display data from related model in admin
- [Answered ]-Line 158, in get_app_config return self.app_configs[app_label] KeyError: 'account'
- [Answered ]-Django REST API get only auth user datas
- [Answered ]-Syncdb error with Django under Windows (OpenKey error?)
- [Answered ]-How to run _icontains method on a foreignkey field in django
- [Answered ]-Python Firebase Admin SDK, Illegal Firebase credential provided