(venv) G:\projects\python\fastprojects>pip list
python-dateutil 2.8.1
python-multipart 0.0.5
rope 0.17.0
@app.post('/token', tags=['safe'])
async def login(form_data: OAuth2PasswordRequestForm = Depends()):
print('form_data', form_data)
user_dict = fake_users_db.get(form_data.username)
if not user_dict:
raise HTTPException(
status_code=400,
detail='Incorrect username or password'
)
user = UserInDB(**user_dict)
hashed_password = fake_hash_password(form_data.password)
if not hashed_password == user.hashed_password:
raise HTTPException(
status_code=400,
detail='Incorrect username or password'
)
return {'access_token': user.username, 'token_type': 'bearer'}
I don't know how to troubleshoot this problem
@q98765543221 pip install python-multipart
Using legacy setup.py install for python-multipart, since package 'wheel' is not installed.
Installing collected packages: python-multipart
Running setup.py install for python-multipart ... done
Successfully installed python-multipart-0.0.5
?[31mERROR?[0m: Error getting request body: The python-multipart library must be installed to use form parsing
.
?[32mINFO?[0m: 127.0.0.1:13645 - "?[1mPOST /token HTTP/1.1?[0m" ?[31m400 Bad Request?[0m
A new project, same error
Are you sure you're running your app in the same environment as the one you're installing python-multipart?
(venv) G:\projects\python\fastapi2>uvicorn main:app --reload --port 8090
?[32mINFO?[0m: Uvicorn running on ?[1mhttp://127.0.0.1:8090?[0m (Press CTRL+C to quit)
?[32mINFO?[0m: Started reloader process [?[36m?[1m10000?[0m] using ?[36m?[1mstatreload?[0m
?[32mINFO?[0m: Started server process [?[36m14376?[0m]
?[32mINFO?[0m: Waiting for application startup.
?[32mINFO?[0m: Application startup complete.
?[32mINFO?[0m: 127.0.0.1:12865 - "?[1mGET /docs HTTP/1.1?[0m" ?[32m200 OK?[0m
?[32mINFO?[0m: 127.0.0.1:12865 - "?[1mGET /openapi.json HTTP/1.1?[0m" ?[32m200 OK?[0m
?[31mERROR?[0m: Error getting request body: The python-multipart library must be installed to use form parsing.
?[32mINFO?[0m: 127.0.0.1:12873 - "?[1mPOST /token HTTP/1.1?[0m" ?[31m400 Bad Request?[0m
?[31mERROR?[0m: Could not stop child process 14376: [Errno 10] No child processes
?[32mINFO?[0m: Stopping reloader process [?[36m?[1m10000?[0m]
(venv) G:\projects\python\fastapi2>pip list
Package Version
fastapi 0.55.1
pip 20.1.1
pydantic 1.5.1
python-multipart 0.0.5
setuptools 47.1.1
six 1.15.0
starlette 0.13.2
wheel 0.34.2
This problem occurs when I use a virtual environment and does not occur when I use a system environment, where the project was created using pyCharm
Thanks for the help here @Kludex ! :clap: :bow:
I understand you solved your problem, so thanks for reporting back and closing the issue @q98765543221 :+1: