Skip to content

Cannot find pandera? #3889

@scheung38

Description

@scheung38

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 searched in Google "How to X in FastAPI" and didn't find any information.
  • I already read and followed all the tutorial in the docs and didn't find an answer.
  • I already checked if it is not related to FastAPI but to Pydantic.
  • I already checked if it is not related to FastAPI but to Swagger UI.
  • I already checked if it is not related to FastAPI but to ReDoc.

Commit to Help

  • I commit to help with one of those options 👆

Example Code

import pandas as pd
import pandera as pa
from icecream import ic
import pycountry
from pathlib import Path
from fastapi import FastAPI

app = FastAPI()

@app.get("/")
def read_and_validate_file(file):
    try:

        if Path(file).suffix == ".csv": 

            test_data = pd.read_csv('data_in/'+file)
            ic('Found csv file!')

        elif Path(file).suffix == ".xlsx":

            test_data = pd.read_excel('data_in/'+file, skiprows=1)
            ic('Found Excel file!')

Description

Without FastAPI the function works as intended using pandera to validate CSV/Excel, but wrapping FastAPI and
then at base of project:

.venv) ➜ export PYTHONPATH=$PWD

then cd into src folder

(.venv) ➜ src git:(master) ✗ uvicorn main:app --reload

File "", line 1030, in _gcd_import
File "", line 1007, in _find_and_load
File "", line 986, in _find_and_load_unlocked
File "", line 680, in _load_unlocked
File "", line 850, in exec_module
File "", line 228, in _call_with_frames_removed
File "/Users/mincheung/Documents/file_processing_pipeline/src/./main.py", line 2, in
import pandera as pa
ModuleNotFoundError: No module named 'pandera'

Operating System

macOS

Operating System Details

Big Sur 11.5.2

FastAPI Version

0.68.1

Python Version

Python 3.9.6

Additional Context

Thank you

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions