Could not find a version that satisfies the requirement pipenv==2021.11.23

I can not figure this out I am trying to deploy a project from git to circleci but any time I try sending a new pull request and send it will have an error

Could not find a version that satisfies the requirement pipenv==2021.5.29 (from versions: ) No matching distribution found for pipenv==2021.5.29

and ModuleNotFoundError: No module named ‘_lzma’

WARNING: The Python lzma extension was not compiled. Missing the lzma lib?

Installed Python-3.6.3 to /root/.pyenv/versions/3.6.3

  • pyenv global 3.6.3
  • pyenv rehash

it will give me this error in the build_docker_image:Build docker image and if I ignore it and try and deploy it to qa or production it will fail.

here is the config.yml file code:

version: 2.1
orbs:
  aws-cli: circleci/aws-cli@2.0.6
  aws-ecr: circleci/aws-ecr@7.3.0

# CircleCI needs variables:
# AWS_DEFAULT_REGION, AWS_ECR_ID, AWS_ACCESS_KEY_ID, AWS_SECRET_ACCESS_KEY,
# PROD_TARGET_GROUP, STAGING_TARGET_GROUP, QA_TARGET_GROUP, CIRCLECI_SG_ID

jobs:
  build_docker_image:
    machine:
        image: ubuntu-2004:202111-02
    steps:
      - checkout
      - aws-cli/install
      - run:
          name: install python 3.6.3
          command: |
            pyenv install 3.6.3
            pyenv global 3.6.3
      - run:
          name: Installing dependencies
          command: |
            set -ex
            sudo update-ca-certificates
            sudo apt-get update
            sudo apt-get install -y build-essential python-setuptools python-dev
            sudo apt-get install -y libpq-dev libjpeg-dev libssl-dev libffi-dev
            sudo apt-get update && sudo apt-get install ca-certificates
            pip install --upgrade pip
            sudo update-ca-certificates
            pip install --index-url=https://pypi.org/simple/ pipenv==2021.5.29
            pip install boto3
            pipenv install --system
      
      - run:
          name: Pulling environment variables
          command: |
            if [ "$CIRCLE_BRANCH" == 'production' ]; then
              export ENV=production
            elif [ "$CIRCLE_BRANCH" == 'staging' ]; then
              export ENV=staging
            else
              export ENV=qa
            fi
            bash ./deployment/circleci/pull-variables ${ENV}
            echo "export ENV=$ENV" >> $BASH_ENV
      - run:
          name: Declaration environmnets
          command: |
              echo "export $(cat .env | grep -v '#' | awk '/=/ {print $1}')" >> $BASH_ENV
      - run :
          name: Add circleci IP to SG
          command: |
            export public_ip_address=$(wget -qO- http://checkip.amazonaws.com)
            echo got ip $public_ip_address
            aws ec2 authorize-security-group-ingress --region "${AWS_DEFAULT_REGION}" --group-id "${CIRCLECI_SG_ID}" --protocol tcp --port 5432 --cidr "$public_ip_address"/32 || exit 1
            echo Added IP to SG
      - run:
          name: Building static files
          command: |
            sed -i "s@credentials_key_id@${AWS_ACCESS_KEY}@" .boto
            sed -i "s@credentials_secret_key@${AWS_SECRET_ACCESS}@" .boto
            if [ "$CIRCLE_BRANCH" == 'production' ]; then
              export $(cat .env | grep -v '#' | awk '/=/ {print $1}') && export AWS_STATIC_STORAGE_BUCKET_NAME=production-blue-manor-education-static && python manage.py collectstatic --no-input && python manage.py compress --force
            elif [ "$CIRCLE_BRANCH" == 'staging' ]; then
              export $(cat .env | grep -v '#' | awk '/=/ {print $1}') && export AWS_STATIC_STORAGE_BUCKET_NAME=staging-blue-manor-education-static && python manage.py collectstatic --no-input && python manage.py compress --force
            elif [ "$CIRCLE_BRANCH" == 'qa' ]; then
              export $(cat .env | grep -v '#' | awk '/=/ {print $1}') && export AWS_STATIC_STORAGE_BUCKET_NAME=qa-blue-manor-education-static && python manage.py collectstatic --no-input && python manage.py compress --force
            else
              echo 'This script is for production, staging, qa branches only'
            fi 
      - run :
          name: Delete circleci IP from SG
          when: always
          command: |
            export public_ip_address=$(wget -qO- http://checkip.amazonaws.com)
            aws ec2 revoke-security-group-ingress --region "${AWS_DEFAULT_REGION}" --group-id "${CIRCLECI_SG_ID}" --protocol tcp --port 5432 --cidr "$public_ip_address"/32
            echo IP removed  
      - aws-ecr/build-and-push-image:
          checkout: false
          attach-workspace: true
          account-url: AWS_ECR_ID
          dockerfile: deployment/circleci/Dockerfile
          path: .
          repo: "${ENV}-blue-manor-education"
          region: AWS_DEFAULT_REGION
          tag: "backend-${CIRCLE_SHA1:0:7}"
      - aws-ecr/build-and-push-image:
          checkout: false
          attach-workspace: true
          account-url: AWS_ECR_ID
          dockerfile: Dockerfile-nginx
          path: deployment/circleci
          repo: "${ENV}-blue-manor-education"
          region: AWS_DEFAULT_REGION
          tag: "nginx-${CIRCLE_SHA1:0:7}"
      - persist_to_workspace:
            root: ./
            paths:
              - ./

  unit_tests:
      docker:
        - image: cimg/python:3.6
      steps:
        - checkout
        - aws-cli/install
        - setup_remote_docker
        - attach_workspace:
            at: ./
        - run:
            name: Declaration environmnets
            command: |
                echo "export $(cat .env | grep -v '#' | awk '/=/ {print $1}')" >> $BASH_ENV
        - run:
            name: Run unit-tests
            no_output_timeout: 30m
            command: |
                sed -i "s@TAG@${CIRCLE_SHA1:0:7}@" deployment/circleci/testing/docker-compose.yml
                sed -i "s@AWS_ECR_ID@${AWS_ECR_ID}@" deployment/circleci/testing/docker-compose.yml
                sed -i "s@ENV@${ENVIRONMENT}@" deployment/circleci/testing/docker-compose.yml
                cd deployment/circleci/testing && bash run-tests $ENVIRONMENT $AWS_ACCESS_KEY_ID $AWS_SECRET_ACCESS_KEY

  delete_docker_images:
    machine:
      enabled: true
    steps:
      - checkout
      - aws-cli/install
      - run:
          name: Deleting the docker image
          command: |
            if !([ "$CIRCLE_BRANCH" == "production" ] || [ "$CIRCLE_BRANCH" == "qa" ] || [ "$CIRCLE_BRANCH" == "staging" ])
            then
              echo 'Deleting images for test branches'
              aws ecr batch-delete-image --repository-name "qa-blue-manor-education" --image-ids imageTag=backend-${CIRCLE_SHA1:0:7} --region $AWS_DEFAULT_REGION
              aws ecr batch-delete-image --repository-name "qa-blue-manor-education" --image-ids imageTag=nginx-${CIRCLE_SHA1:0:7} --region $AWS_DEFAULT_REGION
            fi

  database_migrations:
    docker:
      - image: cimg/python:3.6
    steps:
      - checkout
      - aws-cli/install
      - setup_remote_docker
      - attach_workspace:
          at: ./
      - run:
          name: Declaration environmnets
          command: |
              echo "export $(cat .env | grep -v '#' | awk '/=/ {print $1}')" >> $BASH_ENV
      - run:
          name: Running database migrations
          no_output_timeout: 30m
          command: |
              sed -i "s@TAG@${CIRCLE_SHA1:0:7}@" deployment/circleci/migrations/docker-compose.yml
              sed -i "s@PROJECT_NAME@blue-manor-education@" deployment/circleci/migrations/docker-compose.yml
              sed -i "s@AWS_ECR_ID@${AWS_ECR_ID}@" deployment/circleci/migrations/docker-compose.yml
              sed -i "s@ENV@${ENVIRONMENT}@" deployment/circleci/migrations/docker-compose.yml
              cd deployment/circleci/migrations && bash migration_master $ENVIRONMENT $AWS_ACCESS_KEY_ID $AWS_SECRET_ACCESS_KEY

  deploy:
    docker:
      - image: cimg/python:3.6
    steps:
      - checkout
      - attach_workspace:
          at: ./
      - run:
          name: Declaration environmnets
          command: |
              echo "export $(cat .env | grep -v '#' | awk '/=/ {print $1}')" >> $BASH_ENV
      - run:
          name: Running deploy process
          no_output_timeout: 30m
          command: |
            sed -i "s@TAG@${CIRCLE_SHA1:0:7}@" deployment/circleci/docker-compose.yml
            sed -i "s@ENV@${ENVIRONMENT}@" deployment/circleci/docker-compose.yml
            sed -i "s@AWS_ECR_ID@${AWS_ECR_ID}@" deployment/circleci/docker-compose.yml
            curl -o ./ecs-cli https://amazon-ecs-cli.s3.amazonaws.com/ecs-cli-linux-amd64-latest
            chmod +x ./ecs-cli
            ./ecs-cli configure profile --access-key $AWS_ACCESS_KEY_ID --secret-key $AWS_SECRET_ACCESS_KEY --profile-name default
            ./ecs-cli configure --cluster $ENVIRONMENT-blue-manor-education --region $AWS_DEFAULT_REGION --default-launch-type EC2
            ./ecs-cli compose -f deployment/circleci/docker-compose.yml --ecs-params deployment/circleci/ecs-params.yml --project-name "$ENVIRONMENT-blue-manor-education" \
                service up --cluster-config default --target-group-arn ${TARGET_GROUP_ARN} --container-name nginx --container-port 8080 \
                --role ecsServiceRole --force-deployment --timeout 30

workflows:
  ci_cd:
    jobs:
      - build_docker_image
      - unit_tests:
          requires:
            - build_docker_image

      - delete_docker_images:
          requires:
            - unit_tests

      - database_migrations:
          requires:
            - delete_docker_images
          filters:
            branches:
              only:
                - qa
                - staging
                - production

      - deploy:
          requires:
            - database_migrations
          filters:
            branches:
              only:
                - qa
                - staging
                - production

I tried changing piping version and just getting rid of it and I asked chatgpt to see if it can do it and they all failed!.

small typo I meant “I tried changing “pipenv” version”

Has this ever worked? I’m guessing it may be hard for others to debug without a little more context, but which step is the failure happening in? Did you write this config in the first place, and was it previously working?

Is the pipenv requirement coming from a file somewhere?

One possibility is that the pyenv global bit isn’t getting read (for example, if it’s just modifying shell init files, it might not be getting read in a previous step?) I think pipenv has at least some builtin pyenv support, so that might be another way to go.

Side note: maybe this (in your “Building static files” step) is a little terser and should (maybe with some slight adjustments) do the same thing?

case "$CIRCLE_BRANCH" in
    production|staging|qa)
        export $(awk '!/^#/ && /=/ {print $1}' .env) && export AWS_STATIC_STORAGE_BUCKET_NAME=${CIRCLE_BRANCH}-blue-manor-education-static && python manage.py collectstatic --no-input && python manage.py compress --force
        ;;
    *)
        echo 'This script is for production, staging, qa branches only' >&2
        ;;
esac

it has not all ways been like this. It started when I deployed some new code. At first it worked fine. I was able to deploy and there was almost no errors. But the second time I did it about 2 months later I deployed another thing and it gave me this error. I tried for ever to fix it but it did not work so I deleted the changes I made and it still was not working even though now I technically did not deploy anything so I uploaded it again and same error. Also the error is coming from the build_docker_image. It fails after about 7min on the last step I think “Build docker image” everything else it seems to pass but this one step. And I am not an expert in this stuff so it was like trying to read a book without knowing how to read to try and solve this error. Also I looked it up and the pipenv version i’m trying to access is and old version but still exists. Thank you for your help (:

can no one answer this.