Skip to content

This issue was moved to a discussion.

You can continue the conversation there. Go to discussion →

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Installation error due to missing Rust Tool chain! #2811

Closed
6 tasks done
Jarmos-san opened this issue Feb 15, 2021 · 8 comments
Closed
6 tasks done

Installation error due to missing Rust Tool chain! #2811

Jarmos-san opened this issue Feb 15, 2021 · 8 comments
Labels
question Question or problem question-migrate

Comments

@Jarmos-san
Copy link
Contributor

Jarmos-san commented Feb 15, 2021

First check

  • I added a very descriptive title to this issue.
  • I used the GitHub search to find a similar issue and didn't find it.
  • I searched the FastAPI documentation, with the integrated search.
  • I already read and followed all the tutorial in the docs and didn't find an answer.
  • I already searched in Google "How to X in FastAPI" and didn't find any information.
  • After submitting this, I commit to one of:
    • Read open issues with questions until I find 2 issues where I can help someone and add a comment to help there.
    • I already hit the "watch" button in this repository to receive notifications and I commit to help at least 2 people that ask questions in the future.
    • Implement a Pull Request for a confirmed bug.

Example

Here's a self-contained, minimal, reproducible, example with my use case:

Running pip install fastapi[all] on a 64-bit Windows machine with both PowerShell & Git Bash throws the following error messages:

  Downloading orjson-2.0.7.tar.gz (480 kB)
     |████████████████████████████████| 480 kB 3.3 MB/s
  Installing build dependencies ... done
  Getting requirements to build wheel ... done
    Preparing wheel metadata ... error
    ERROR: Command errored out with exit status 1:
     command: 'e:\.venv\scripts\python.exe' 'e:\.venv\lib\site-packages\pip\_vendor\pep517\_in_process.py' prepare_metadata_for_build_wheel 'C:\Users\Space\AppData\Local\Temp\tmpm9nrvczg'
         cwd: C:\Users\Space\AppData\Local\Temp\pip-install-00q6owq6\orjson_a4eb6a5c825b4f828cea239cebcbe77d
    Complete output (6 lines):

    Cargo, the Rust package manager, is not installed or is not on PATH.
    This package requires Rust and Cargo to compile extensions. Install it through
    the system's package manager or via https://rustup.rs/

    Checking for Rust toolchain....
    ----------------------------------------

...

  ERROR: Command errored out with exit status 1:
   command: 'e:\.venv\scripts\python.exe' 'e:\.venv\lib\site-packages\pip\_vendor\pep517\_in_process.py' build_wheel 'C:\Users\Space\AppData\Local\Temp\tmpgw763q8v'
       cwd: C:\Users\Space\AppData\Local\Temp\pip-install-00q6owq6\ujson_abdb3dae46ca4793baf685983dac867b
  Complete output (5 lines):
  running bdist_wheel
  running build
  running build_ext
  building 'ujson' extension
  error: Microsoft Visual C++ 14.0 or greater is required. Get it with "Microsoft C++ Build Tools": https://visualstudio.microsoft.com/visual-cpp-build-tools/
  ----------------------------------------
  ERROR: Failed building wheel for ujson
Failed to build ujson
ERROR: Could not build wheels for ujson which use PEP 517 and cannot be installed directly

NOTE: The messages has been truncated since it repeats itself countless times as pip keeps retrying to install orjson.

Description

Running the pip install fastapi[all] command breaks due to missing Rust toolchains in the system on a 64-bit Windows 10 machine. Not sure why it's even required. Am I missing something out?

But installing the requirements individually works flawlessly. This breakage has been tested both on PowerShell & Git Bash. But I can't test it on WSL as of now due to time constraints.

Environment

  • OS: [e.g. Linux / Windows / macOS]: Windows 10 64-bit.
  • FastAPI Version [e.g. 0.3.0]: latest
  • Python version: 3.8.5
@Jarmos-san Jarmos-san added the question Question or problem label Feb 15, 2021
@ycd
Copy link
Contributor

ycd commented Feb 15, 2021

Not sure why it's even required. Am I missing something out?

It is not required, only if you want to use UJSONResponse, in your case looks like ujson has some C++ dependencies which you don't have on your machine.

@Jarmos-san
Copy link
Contributor Author

It is not required, only if you want to use UJSONResponse, in your case looks like ujson has some C++ dependencies which you don't have on your machine.

Ah, I see! It makes sense now. In that context, I guess the issue could be related to #820 as well. Leaving it open for now then.

cc @tiangolo

@ycd
Copy link
Contributor

ycd commented Feb 16, 2021

Well, sure. The #820 is no more valid since they found a maintainer but Starlette recently dropped down support for UJSONResponse.

#2335 re-added to make Starlette upgrade non breaking-change but on the other hand C dependencies breaking builds too, kinda tricky one.

@tiangolo
Copy link
Owner

Thanks for the help @ycd ! 🙇

@Jarmos-san I think it's very probable that you are using an old version of pip not supporting wheels, or at least not some wheels. If you use a recent version of pip, it should fetch the compiled wheels and not require building anything.

Try this in a PowerShell:

$ python -m venv env

$ .\env\Scripts\Activate.ps1

# This is the key, upgrade pip inside your virtual environment
$ python -m pip install --upgrade pip

$ python -m pip install "fastapi[all]"

Downloading pydantic-1.8.1-cp36-cp36m-manylinux2014_x86_64.whl
...
Downloading orjson-3.5.2-cp36-cp36m-manylinux2014_x86_64.whl
...
Downloading ujson-3.2.0-cp36-cp36m-manylinux1_x86_64.whl

...of course, in your case it would download Windows versions, not Linux versions. But it should work the same without needing to compile anything.

@Jarmos-san
Copy link
Contributor Author

Jarmos-san commented May 10, 2021

@tiangolo thanks for responding back & first things first, thanks for creating FastAPI.

As for the issue, it's still not resolved on my machine. For further reference I'm using pip v21.1.1 which I assume is the latest as of writing this comment.

But to be honest, it's a trivial issue in my opinion. I've been using FastAPI for a couple of my projects. And, I didn't come across any dependency issues as long as I download each of them specifically. I'm also not sure how to debug this type of issues so I can close the issue if need be.

Do let me know, what you think?

PS: I think it would be wise to add a small heads-up text in the documentations stating this issue for Windows users. Pip can't actually install orjson on Windows 10 & it could be related to this issue ijl/orjson#19

@github-actions github-actions bot removed the answered label May 10, 2021
@tiangolo
Copy link
Owner

That's strange, I just restarted in Windows to test this, and it worked as expected with PowerShell, in a freshly created environment:

PowerShell logs 👈
PS C:\Users\User\code\test-rusty> python -m venv env
PS C:\Users\User\code\test-rusty> .\env\Scripts\Activate.ps1
(env) PS C:\Users\User\code\test-rusty> get-command python                                                              
CommandType     Name                                               Version    Source
-----------     ----                                               -------    ------
Application     python.exe                                         3.8.315... C:\Users\User\code\test-rusty\env\Scri...


(env) PS C:\Users\User\code\test-rusty> pip --version                                                                   pip 19.2.3 from c:\users\user\code\test-rusty\env\lib\site-packages\pip (python 3.8)
(env) PS C:\Users\User\code\test-rusty> python -m pip install -U pip                                                    Collecting pip
  Downloading https://files.pythonhosted.org/packages/cd/6f/43037c7bcc8bd8ba7c9074256b1a11596daa15555808ec748048c1507f08/pip-21.1.1-py3-none-any.whl (1.5MB)
     |████████████████████████████████| 1.6MB 3.2MB/s
Installing collected packages: pip
  Found existing installation: pip 19.2.3
    Uninstalling pip-19.2.3:
      Successfully uninstalled pip-19.2.3
Successfully installed pip-21.1.1
(env) PS C:\Users\User\code\test-rusty> get-command pip                                                                 
CommandType     Name                                               Version    Source
-----------     ----                                               -------    ------
Application     pip.exe                                            0.0.0.0    C:\Users\User\code\test-rusty\env\Scri...


(env) PS C:\Users\User\code\test-rusty> pip --version                                                                   pip 21.1.1 from c:\users\user\code\test-rusty\env\lib\site-packages\pip (python 3.8)
(env) PS C:\Users\User\code\test-rusty> pip install fastapi[all]
Collecting fastapi[all]
  Downloading fastapi-0.65.0-py3-none-any.whl (50 kB)
     |████████████████████████████████| 50 kB 3.4 MB/s
Collecting pydantic<2.0.0,>=1.0.0
  Downloading pydantic-1.8.1-cp38-cp38-win_amd64.whl (2.0 MB)
     |████████████████████████████████| 2.0 MB 6.4 MB/s
Collecting starlette==0.14.2
  Downloading starlette-0.14.2-py3-none-any.whl (60 kB)
     |████████████████████████████████| 60 kB 3.5 MB/s
Collecting aiofiles<0.6.0,>=0.5.0
  Downloading aiofiles-0.5.0-py3-none-any.whl (11 kB)
Collecting jinja2<3.0.0,>=2.11.2
  Downloading Jinja2-2.11.3-py2.py3-none-any.whl (125 kB)
     |████████████████████████████████| 125 kB 6.4 MB/s
Collecting pyyaml<6.0.0,>=5.3.1
  Downloading PyYAML-5.4.1-cp38-cp38-win_amd64.whl (213 kB)
     |████████████████████████████████| 213 kB ...
Collecting graphene<3.0.0,>=2.1.8
  Using cached graphene-2.1.8-py2.py3-none-any.whl (107 kB)
Collecting itsdangerous<2.0.0,>=1.1.0
  Using cached itsdangerous-1.1.0-py2.py3-none-any.whl (16 kB)
Collecting requests<3.0.0,>=2.24.0
  Downloading requests-2.25.1-py2.py3-none-any.whl (61 kB)
     |████████████████████████████████| 61 kB 4.0 MB/s
Collecting ujson<5.0.0,>=4.0.1
  Downloading ujson-4.0.2-cp38-cp38-win_amd64.whl (44 kB)
     |████████████████████████████████| 44 kB ...
Collecting async_generator<2.0.0,>=1.10
  Using cached async_generator-1.10-py3-none-any.whl (18 kB)
Collecting async_exit_stack<2.0.0,>=1.0.1
  Using cached async_exit_stack-1.0.1-py3-none-any.whl (4.7 kB)
Collecting orjson<4.0.0,>=3.2.1
  Downloading orjson-3.5.2-cp38-none-win_amd64.whl (177 kB)
     |████████████████████████████████| 177 kB ...
Collecting email_validator<2.0.0,>=1.1.1
  Downloading email_validator-1.1.2-py2.py3-none-any.whl (17 kB)
Collecting uvicorn[standard]<0.14.0,>=0.12.0
  Downloading uvicorn-0.13.4-py3-none-any.whl (46 kB)
     |████████████████████████████████| 46 kB 3.2 MB/s
Collecting python-multipart<0.0.6,>=0.0.5
  Using cached python-multipart-0.0.5.tar.gz (32 kB)
Collecting idna>=2.0.0
  Downloading idna-3.1-py3-none-any.whl (58 kB)
     |████████████████████████████████| 58 kB ...
Collecting dnspython>=1.15.0
  Downloading dnspython-2.1.0-py3-none-any.whl (241 kB)
     |████████████████████████████████| 241 kB ...
Collecting graphql-core<3,>=2.1
  Downloading graphql_core-2.3.2-py2.py3-none-any.whl (252 kB)
     |████████████████████████████████| 252 kB ...
Collecting graphql-relay<3,>=2
  Using cached graphql_relay-2.0.1-py3-none-any.whl (20 kB)
Collecting aniso8601<=7,>=3
  Using cached aniso8601-7.0.0-py2.py3-none-any.whl (42 kB)
Collecting six<2,>=1.10.0
  Downloading six-1.16.0-py2.py3-none-any.whl (11 kB)
Collecting promise<3,>=2.3
  Using cached promise-2.3.tar.gz (19 kB)
Collecting rx<2,>=1.6
  Using cached Rx-1.6.1-py2.py3-none-any.whl (179 kB)
Collecting MarkupSafe>=0.23
  Using cached MarkupSafe-1.1.1-cp38-cp38-win_amd64.whl (16 kB)
Collecting typing-extensions>=3.7.4.3
  Downloading typing_extensions-3.10.0.0-py3-none-any.whl (26 kB)
Collecting idna>=2.0.0
  Downloading idna-2.10-py2.py3-none-any.whl (58 kB)
     |████████████████████████████████| 58 kB ...
Collecting urllib3<1.27,>=1.21.1
  Downloading urllib3-1.26.4-py2.py3-none-any.whl (153 kB)
     |████████████████████████████████| 153 kB ...
Collecting certifi>=2017.4.17
  Downloading certifi-2020.12.5-py2.py3-none-any.whl (147 kB)
     |████████████████████████████████| 147 kB ...
Collecting chardet<5,>=3.0.2
  Downloading chardet-4.0.0-py2.py3-none-any.whl (178 kB)
     |████████████████████████████████| 178 kB 6.4 MB/s
Collecting h11>=0.8
  Downloading h11-0.12.0-py3-none-any.whl (54 kB)
     |████████████████████████████████| 54 kB 707 kB/s
Collecting click==7.*
  Downloading click-7.1.2-py2.py3-none-any.whl (82 kB)
     |████████████████████████████████| 82 kB 515 kB/s
Collecting watchgod>=0.6
  Downloading watchgod-0.7-py3-none-any.whl (11 kB)
Collecting colorama>=0.4
  Downloading colorama-0.4.4-py2.py3-none-any.whl (16 kB)
Collecting python-dotenv>=0.13
  Downloading python_dotenv-0.17.1-py2.py3-none-any.whl (18 kB)
Collecting websockets==8.*
  Using cached websockets-8.1-cp38-cp38-win_amd64.whl (66 kB)
Using legacy 'setup.py install' for promise, since package 'wheel' is not installed.
Using legacy 'setup.py install' for python-multipart, since package 'wheel' is not installed.
Installing collected packages: six, rx, promise, typing-extensions, h11, graphql-core, click, websockets, watchgod, uvicorn, urllib3, starlette, pyyaml, python-dotenv, pydantic, MarkupSafe, idna, graphql-relay, dnspython, colorama, chardet, certifi, aniso8601, ujson, requests, python-multipart, orjson, jinja2, itsdangerous, graphene, fastapi, email-validator, async-generator, async-exit-stack, aiofiles
    Running setup.py install for promise ... done
    Running setup.py install for python-multipart ... done
Successfully installed MarkupSafe-1.1.1 aiofiles-0.5.0 aniso8601-7.0.0 async-exit-stack-1.0.1 async-generator-1.10 certifi-2020.12.5 chardet-4.0.0 click-7.1.2 colorama-0.4.4 dnspython-2.1.0 email-validator-1.1.2 fastapi-0.65.0 graphene-2.1.8 graphql-core-2.3.2 graphql-relay-2.0.1 h11-0.12.0 idna-2.10 itsdangerous-1.1.0 jinja2-2.11.3 orjson-3.5.2 promise-2.3 pydantic-1.8.1 python-dotenv-0.17.1 python-multipart-0.0.5 pyyaml-5.4.1 requests-2.25.1 rx-1.6.1 six-1.16.0 starlette-0.14.2 typing-extensions-3.10.0.0 ujson-4.0.2 urllib3-1.26.4 uvicorn-0.13.4 watchgod-0.7 websockets-8.1
(env) PS C:\Users\User\code\test-rusty>

But anyway, I'm glad you solved your problem. I guess we can probably close this issue then.

And if someone else finds a way to replicate the problem we can check it again.

@anindyamanna
Copy link

Thanks for the help @ycd ! 🙇

@Jarmos-san I think it's very probable that you are using an old version of pip not supporting wheels, or at least not some wheels. If you use a recent version of pip, it should fetch the compiled wheels and not require building anything.

Try this in a PowerShell:

$ python -m venv env

$ .\env\Scripts\Activate.ps1

# This is the key, upgrade pip inside your virtual environment
$ python -m pip install --upgrade pip

$ python -m pip install "fastapi[all]"

Downloading pydantic-1.8.1-cp36-cp36m-manylinux2014_x86_64.whl
...
Downloading orjson-3.5.2-cp36-cp36m-manylinux2014_x86_64.whl
...
Downloading ujson-3.2.0-cp36-cp36m-manylinux1_x86_64.whl

...of course, in your case it would download Windows versions, not Linux versions. But it should work the same without needing to compile anything.

Thanks @tiangolo I had the same problem and updating pip solved it. :)

@scign
Copy link

scign commented Sep 21, 2021

I also encountered this but I found that switching to a 64-bit python environment fixed the issue for me. I was already using pip 21.2.4 so pip was up to date.

@tiangolo tiangolo changed the title [BUG] Installation error due to missing Rust Tool chain! Installation error due to missing Rust Tool chain! Feb 24, 2023
@tiangolo tiangolo reopened this Feb 27, 2023
@github-actions github-actions bot removed the answered label Feb 27, 2023
Repository owner locked and limited conversation to collaborators Feb 27, 2023
@tiangolo tiangolo converted this issue into discussion #6843 Feb 27, 2023

This issue was moved to a discussion.

You can continue the conversation there. Go to discussion →

Labels
question Question or problem question-migrate
Projects
None yet
Development

No branches or pull requests

5 participants