한규범
한규범

Reputation: 21

An error occurred while installing a package using pipenv in the django project

It seems that pipenv lock itself is not working. Below is the error content. Is there a solution?

ERROR:pip.subprocessor:[present-rich] Getting requirements to build wheel exited with 1
[ResolutionFailure]:   File "/home/ubuntu/.local/lib/python3.10/site-packages/pipenv/resolver.py", line 811, in _main
[ResolutionFailure]:       resolve_packages(
[ResolutionFailure]:   File "/home/ubuntu/.local/lib/python3.10/site-packages/pipenv/resolver.py", line 759, in resolve_packages
[ResolutionFailure]:       results, resolver = resolve(
[ResolutionFailure]:   File "/home/ubuntu/.local/lib/python3.10/site-packages/pipenv/resolver.py", line 738, in resolve
[ResolutionFailure]:       return resolve_deps(
[ResolutionFailure]:   File "/home/ubuntu/.local/lib/python3.10/site-packages/pipenv/utils/resolver.py", line 1154, in resolve_deps
[ResolutionFailure]:       results, hashes, markers_lookup, resolver, skipped = actually_resolve_deps(
[ResolutionFailure]:   File "/home/ubuntu/.local/lib/python3.10/site-packages/pipenv/utils/resolver.py", line 953, in actually_resolve_deps
[ResolutionFailure]:       resolver.resolve()
[ResolutionFailure]:   File "/home/ubuntu/.local/lib/python3.10/site-packages/pipenv/utils/resolver.py", line 700, in resolve
[ResolutionFailure]:       raise ResolutionFailure(message=str(e))
[pipenv.exceptions.ResolutionFailure]: Warning: Your dependencies could not be resolved. You likely have a mismatch in your sub-dependencies.
  You can use $ pipenv install --skip-lock to bypass this mechanism, then run $ pipenv graph to inspect the situation.
  Hint: try $ pipenv lock --pre if it is a pre-release dependency.
ERROR: Getting requirements to build wheel exited with 1

Traceback (most recent call last):
  File "/home/ubuntu/.local/bin/pipenv", line 8, in <module>
    sys.exit(cli())
  File "/home/ubuntu/.local/lib/python3.10/site-packages/pipenv/vendor/click/core.py", line 1130, in __call__
    return self.main(*args, **kwargs)
  File "/home/ubuntu/.local/lib/python3.10/site-packages/pipenv/cli/options.py", line 58, in main
    return super().main(*args, **kwargs, windows_expand_args=False)
  File "/home/ubuntu/.local/lib/python3.10/site-packages/pipenv/vendor/click/core.py", line 1055, in main
    rv = self.invoke(ctx)
  File "/home/ubuntu/.local/lib/python3.10/site-packages/pipenv/vendor/click/core.py", line 1657, in invoke
    return _process_result(sub_ctx.command.invoke(sub_ctx))
  File "/home/ubuntu/.local/lib/python3.10/site-packages/pipenv/vendor/click/core.py", line 1404, in invoke
    return ctx.invoke(self.callback, **ctx.params)
  File "/home/ubuntu/.local/lib/python3.10/site-packages/pipenv/vendor/click/core.py", line 760, in invoke
    return __callback(*args, **kwargs)
  File "/home/ubuntu/.local/lib/python3.10/site-packages/pipenv/vendor/click/decorators.py", line 84, in new_func
    return ctx.invoke(f, obj, *args, **kwargs)
  File "/home/ubuntu/.local/lib/python3.10/site-packages/pipenv/vendor/click/core.py", line 760, in invoke
    return __callback(*args, **kwargs)
  File "/home/ubuntu/.local/lib/python3.10/site-packages/pipenv/vendor/click/decorators.py", line 26, in new_func
    return f(get_current_context(), *args, **kwargs)
  File "/home/ubuntu/.local/lib/python3.10/site-packages/pipenv/cli/command.py", line 579, in update
    do_update(
  File "/home/ubuntu/.local/lib/python3.10/site-packages/pipenv/routines/update.py", line 69, in do_update
    do_lock(
  File "/home/ubuntu/.local/lib/python3.10/site-packages/pipenv/routines/lock.py", line 79, in do_lock
    venv_resolve_deps(
  File "/home/ubuntu/.local/lib/python3.10/site-packages/pipenv/utils/resolver.py", line 1096, in venv_resolve_deps
    c = resolve(cmd, st, project=project)
  File "/home/ubuntu/.local/lib/python3.10/site-packages/pipenv/utils/resolver.py", line 990, in resolve
    raise RuntimeError("Failed to lock Pipfile.lock!")
RuntimeError: Failed to lock Pipfile.lock!

Below is the result of trying the installed Pipfile and pipenv graph, but I don't know how to solve the problem. It's impossible to lock it. It seems to be a wheel or uwsgi problem, but I don't know how to solve it.

Pipfile

[[source]]
url = "https://pypi.org/simple"
verify_ssl = true
name = "pypi"

[packages]
django = "==4.2"
djangorestframework = "*"
django-cors-headers = "*"
pyjwt = "*"
djangorestframework-simplejwt = "*"
python-dotenv = "*"
pillow = "*"
wheel = "*"
boto3 = "*"
django-storages = "*"
mysqlclient = "*"
dj-rest-auth = "*"
django-allauth = "*"
uwsgi = "*"
setuptools = "*"
pip = "*"

[dev-packages]
black = "*"

[requires]
python_version = "3.10"

$ pipenv graph

"Pipfile" 28L, 444B                                                                                                                        23,0-1        All
    - python-dateutil [required: >=2.1,<3.0.0, installed: 2.8.2]
      - six [required: >=1.5, installed: 1.16.0]
    - urllib3 [required: >=1.25.4,<1.27, installed: 1.26.16]
  - jmespath [required: >=0.7.1,<2.0.0, installed: 1.0.1]
  - s3transfer [required: >=0.6.0,<0.7.0, installed: 0.6.1]
    - botocore [required: >=1.12.36,<2.0a.0, installed: 1.29.146]
      - jmespath [required: >=0.7.1,<2.0.0, installed: 1.0.1]
      - python-dateutil [required: >=2.1,<3.0.0, installed: 2.8.2]
        - six [required: >=1.5, installed: 1.16.0]
      - urllib3 [required: >=1.25.4,<1.27, installed: 1.26.16]
django-cors-headers==4.0.0
  - Django [required: >=3.2, installed: 4.2]
    - asgiref [required: >=3.6.0,<4, installed: 3.7.2]
      - typing-extensions [required: >=4, installed: 4.6.3]
    - sqlparse [required: >=0.3.1, installed: 0.4.4]
django-storages==1.13.2
  - Django [required: >=3.2, installed: 4.2]
    - asgiref [required: >=3.6.0,<4, installed: 3.7.2]
      - typing-extensions [required: >=4, installed: 4.6.3]
    - sqlparse [required: >=0.3.1, installed: 0.4.4]
djangorestframework-simplejwt==5.2.2
  - django [required: Any, installed: 4.2]
    - asgiref [required: >=3.6.0,<4, installed: 3.7.2]
      - typing-extensions [required: >=4, installed: 4.6.3]
    - sqlparse [required: >=0.3.1, installed: 0.4.4]
  - djangorestframework [required: Any, installed: 3.14.0]
    - django [required: >=3.0, installed: 4.2]
      - asgiref [required: >=3.6.0,<4, installed: 3.7.2]
        - typing-extensions [required: >=4, installed: 4.6.3]
      - sqlparse [required: >=0.3.1, installed: 0.4.4]
    - pytz [required: Any, installed: 2023.3]
  - pyjwt [required: >=1.7.1,<3, installed: 2.7.0]
mysqlclient==2.1.1
Pillow==9.5.0
python-dotenv==1.0.0
uWSGI==2.0.21

Upvotes: 1

Views: 7505

Answers (3)

Biswajit Biswas
Biswajit Biswas

Reputation: 11

I was also facing the same issue with my Mac. I have tried two different steps:

Step-1: I ran the two comments below, and the issue has been resolved:

brew install mysql pkg-config
pip install mysqlclient

Step-2: I set up my project from the very beginning and ran the below command from the terminal(From the server).

pipenv install mysqlclient

Thanks :)

Upvotes: 0

fsan
fsan

Reputation: 118

For me, what happened is that a package was added to Pipfile but it did not exist in Pypi. For some reason, instead of failing saying there was an invalid package, it just returned me this unhelpful message.

I removed the current Pipfile.lock and revised my Pipfile and found the culprid. I removed the faulty line and used pipenv sync and everything worked again.

Upvotes: 0

한규범
한규범

Reputation: 21

The problem has been resolved! It was a problem caused by the different Python version between the local(mac M1 silicon) and the distribution environment. The base virtual environment was run automatically because the conda was used in the local environment and was created in version 3.9.

There may be people who have experienced the same problem as me, so I leave a solution below.

  1. Clear all Pipfile, Pipfile.lock in the server environment and reinstall the package
  2. git pull, remove all created virtual environments including conda from local environment
  3. Create a virtual environment with $pipenv --python 3.10 that matches the deployment environment
  4. Pipenv install in local environment

To avoid any dependency issues between deployment and local , recommend pushing both Pipfile and Pipfile.lock.

Upvotes: 1

Related Questions