Home > Software engineering >  ERROR: Could not find a version that satisfies the requirement rest-framework (unavailable) (from ve
ERROR: Could not find a version that satisfies the requirement rest-framework (unavailable) (from ve

Time:10-18

I'm a beginner and I'm getting this error, can someone with more experience help me?

  • ERROR: Could not find a version that satisfies the requirement rest-framework (unavailable) (from versions: none)

  • ERROR: No matching distribution found for rest-framework (unavailable)

  • ERROR: Service 'web' failed to build : Build failed

I've tried using the commands below but it didn't solve the problem.

pip install djangorestframework-jsonapi

pip3 install djangorestframework-jsonapi

pip install -r requirements.txt --proxy address:port

python -m pip install --upgrade pip

  1. python3 --version

    • Python 3.10.6
  2. print(django.get_version())

    • 3.2.12
  3. pip show djangorestframework

    • Name: djangorestframework / Version: 3.14.0
  4. cat /etc/os-release

    • PRETTY_NAME="Ubuntu 22.04.1 LTS"

CodePudding user response:

Your error messages says

ERROR: Could not find a version that satisfies the requirement rest-framework (unavailable) (from versions: none)

which means that your requirements.txt file is listing rest-framework as a requirement. However, there is no such module listed on PyPI. Did you mean to use python-rest-framework instead, or some other django-specific package?

Fix your requirements.txt file to make sure it correctly lists your dependencies, and things should work. To make sure you have the correct package name, it should exist on https://pypi.org. https://pypi.org/search/?q=rest-framework lists a number of possibilities you might have meant to use.

PS: pip install djangorestframework-jsonapi already installed module rest_framework for me, so maybe the correct replacement for rest-framework in your requirements.txt is simply pip install djangorestframework-jsonapi.

See also: https://django-rest-framework-json-api.readthedocs.io/en/stable/getting-started.html#installation

  • Related