Resolving orjson dependency conflict when installing django-unicorn in Windows

For those you run

pipenv install django-unicorn

And you get a depedency resolution conflict relating to orjson like this:

django-unicorn 0.2.2 depends on orjson<4.0.0 and >=3.2.1
    django-unicorn 0.2.1 depends on orjson<4.0.0 and >=3.2.1
    django-unicorn 0.2.0 depends on orjson<4.0.0 and >=3.2.1
    django-unicorn 0.1.1 depends on orjson<4.0.0 and >=3.2.1
    django-unicorn 0.1.0 depends on orjson<4.0.0 and >=3.2.1

To fix this you could try to:
1. loosen the range of package versions you've specified
2. remove package versions to allow pip attempt to solve the dependency con

-- then you get plenty of this sort of error below:

WARNING: Discarding
256=8e85b607b32adbccfd72ac6b8a1205c523d10eb7b37b46ec142e7f55344710b0 (from (requires-python:>=3.6). Command errored o
ut with exit status 1: 'c:\users\andy\.virtualenvs\stud_book-kbrsqal2\scrip
ages\pip\_vendor\pep517\in_process\' prepare_metadata_for_bui
ld_wheel 'C:\Users\Andy\AppData\Local\Temp\tmp9w3u58fn' Check the logs for
full command output.
ERROR: Cannot install -r c:\users\andy\appdata\local\temp\pipenv-q7m541g4-r
versions have conflicting dependencies.

Then you are probably running a 32 bit version of python.

orjson needs a 64 bit version.

To fix this I am assuming you are:

  1. Running on Windows
  2. using pipenv

To find out what version of python your are running type:

You will get something like this:

Python 3.7.1 (v3.7.1:260ec2c36a, Oct 20 2018, 14:05:16) [MSC v.1915 32 bit (Intel)] on win32
Type "help", "copyright", "credits" or "license" for more information.

Notice how it says 32 bit in the first line?

If it does – we need to install 64 bit python.

To do that go to the Python Windows package list

And pick a 64 bit version.

At the time of this article I installed the Python 3.9.7 64 bit version.

Once installed you will need to update the Pipfile (if you are using pipenv) to be [requires] python_version = "3.9"

Then you’ll need to clean up your pipenv shell:

pipenv --rm

Then rebuild it:

pipenv install

pipenv shell

Then you should be able to:

pipenv install django-unicorn

And success!

pipenv install django-unicorn
Installing django-unicorn...
Adding django-unicorn to Pipfile's [packages]...
Installation Succeeded
Pipfile.lock (1dc94b) out of date, updating to (72e6d2)...
Locking [dev-packages] dependencies...
Locking [packages] dependencies...
           Building requirements...
Resolving dependencies...
Updated Pipfile.lock (72e6d2)!
Installing dependencies from Pipfile.lock (72e6d2)...
  ================================ 0/0 - 00:00:00

Leave a Reply