Cannot run or debug FASTAPI project using PyCharm on Linux Mint XFCE.

Cannot run or debug FASTAPI project using PyCharm on Linux Mint XFCE.

 

I have my FASTAPI SELENIUM PYTHON Project in the following structure :
.
├── APIRunner.egg-info
│   ├── dependency_links.txt
│   ├── PKG-INFO
│   ├── SOURCES.txt
│   └── top_level.txt
├── Controllers
│   ├── AccessLevel
│   │   ├── AccessLevelAdd.py
│   │   ├── AccessLevelDelete.py
│   │   ├── AccessLevelEdit.py
│   │   ├── AccessLevelList.py
│   │   ├── __init__.py
│   │   └── __pycache__
│   │       ├── AccessLevelAdd.cpython-310.pyc
│   │       ├── AccessLevelDelete.cpython-310.pyc
│   │       ├── AccessLevelEdit.cpython-310.pyc
│   │       ├── AccessLevelList.cpython-310.pyc
│   │       └── __init__.cpython-310.pyc
│   ├── AccountOwner
│   │   ├── AccountOwnerActivateDisableBrand.py
│   │   ├── AccountOwnerAutoLogin.py
│   │   ├── AccountOwnerList.py
│   │   ├── __init__.py
│   │   └── __pycache__
│   │       ├── AccountOwnerActivateDisableBrand.cpython-310.pyc
│   │       ├── AccountOwnerAutoLogin.cpython-310.pyc
│   │       ├── AccountOwnerList.cpython-310.pyc
│   │       └── __init__.cpython-310.pyc
│   ├── Authentication
│   │   ├── __init__.py
│   │   ├── Login.py
│   │   ├── Logout.py
│   │   └── __pycache__
│   │       ├── __init__.cpython-310.pyc
│   │       ├── Login.cpython-310.pyc
│   │       └── Logout.cpython-310.pyc
│   ├── Dashboard
│   │   ├── Dashboard.py
│   │   ├── __init__.py
│   │   └── __pycache__
│   │       ├── Dashboard.cpython-310.pyc
│   │       └── __init__.cpython-310.pyc
│   ├── Documentation
│   │   ├── Authentication.py
│   │   ├── GetEndpoints.py
│   │   ├── __init__.py
│   │   └── __pycache__
│   │       ├── Authentication.cpython-310.pyc
│   │       ├── GetEndpoints.cpython-310.pyc
│   │       └── __init__.cpython-310.pyc
│   ├── GeneralSettings
│   │   ├── GeneralSettingsList.py
│   │   ├── __init__.py
│   │   └── __pycache__
│   │       ├── GeneralSettingsList.cpython-310.pyc
│   │       └── __init__.cpython-310.pyc
│   ├── __init__.py
│   ├── Profile
│   │   ├── __init__.py
│   │   ├── InternetCash.py
│   │   ├── MyProfileSection.py
│   │   ├── NotificationSection.py
│   │   └── __pycache__
│   │       ├── __init__.cpython-310.pyc
│   │       ├── InternetCash.cpython-310.pyc
│   │       ├── MyProfileSection.cpython-310.pyc
│   │       └── NotificationSection.cpython-310.pyc
│   ├── ProjectwheelFeedback
│   │   ├── __init__.py
│   │   └── ProjechwheelFeedbackAdd.py
│   ├── __pycache__
│   │   └── __init__.cpython-310.pyc
│   └── Tester
│       ├── APIForTesting.py
│       ├── __init__.py
│       ├── __pycache__
│       │   ├── APIForTesting.cpython-310.pyc
│       │   └── __init__.cpython-310.pyc
│       └── ScriptForTesting.py
├── DataModels
│   ├── AuthenticationModel
│   │   ├── AuthenticationModel.py
│   │   ├── __init__.py
│   │   └── __pycache__
│   │       ├── AuthenticationModel.cpython-310.pyc
│   │       └── __init__.cpython-310.pyc
│   ├── __init__.py
│   └── __pycache__
│       └── __init__.cpython-310.pyc
├── Environment_Variables.py
├── Fast-API-Base.py
├── __init__.py
├── __pycache__
│   ├── Environment_Variables.cpython-310.pyc
│   └── Fast-API-Base.cpython-310.pyc
├── Routes
│   ├── __init__.py
│   ├── __pycache__
│   │   ├── __init__.cpython-310.pyc
│   │   └── routes.cpython-310.pyc
│   └── routes.py
├── SelePy
│   ├── __init__.py
│   ├── Locators
│   │   ├── AccessLevel
│   │   │   ├── AccessLevelListPageLocators.py
│   │   │   ├── __init__.py
│   │   │   └── __pycache__
│   │   │       ├── AccessLevelListPageLocators.cpython-310.pyc
│   │   │       └── __init__.cpython-310.pyc
│   │   ├── AccountOwnerList
│   │   │   ├── AccountOwnerAutologinLocators.py
│   │   │   ├── AccountOwnerListLocators.py
│   │   │   ├── __init__.py
│   │   │   └── __pycache__
│   │   │       ├── AccountOwnerAutologinLocators.cpython-310.pyc
│   │   │       ├── AccountOwnerListLocators.cpython-310.pyc
│   │   │       └── __init__.cpython-310.pyc
│   │   ├── Authentication
│   │   │   ├── BaseLocators.py
│   │   │   ├── __init__.py
│   │   │   ├── LoginLocators.py
│   │   │   └── __pycache__
│   │   │       ├── BaseLocators.cpython-310.pyc
│   │   │       ├── __init__.cpython-310.pyc
│   │   │       └── LoginLocators.cpython-310.pyc
│   │   ├── Base
│   │   │   ├── BaseLocators.py
│   │   │   ├── __init__.py
│   │   │   └── __pycache__
│   │   │       ├── BaseLocators.cpython-310.pyc
│   │   │       └── __init__.cpython-310.pyc
│   │   ├── Dashboard
│   │   │   ├── AdminDashboardLocators.py
│   │   │   ├── __init__.py
│   │   │   └── __pycache__
│   │   │       ├── AdminDashboardLocators.cpython-310.pyc
│   │   │       └── __init__.cpython-310.pyc
│   │   ├── GeneralSettingsList
│   │   │   ├── GeneralSettingsListLocators.py
│   │   │   ├── __init__.py
│   │   │   └── __pycache__
│   │   │       ├── GeneralSettingsListLocators.cpython-310.pyc
│   │   │       └── __init__.cpython-310.pyc
│   │   ├── __init__.py
│   │   ├── Profile
│   │   │   ├── __init__.py
│   │   │   ├── MyProfileLocators.py
│   │   │   └── __pycache__
│   │   │       ├── __init__.cpython-310.pyc
│   │   │       └── MyProfileLocators.cpython-310.pyc
│   │   └── __pycache__
│   │       └── __init__.cpython-310.pyc
│   ├── PageObjects
│   │   ├── AccessLevel
│   │   │   ├── AccessLevelList.py
│   │   │   ├── __init__.py
│   │   │   └── __pycache__
│   │   │       ├── AccessLevelList.cpython-310.pyc
│   │   │       └── __init__.cpython-310.pyc
│   │   ├── AccountOwner
│   │   │   ├── AccountOwnerList.py
│   │   │   ├── __init__.py
│   │   │   └── __pycache__
│   │   │       ├── AccountOwnerList.cpython-310.pyc
│   │   │       └── __init__.cpython-310.pyc
│   │   ├── Authentication
│   │   │   ├── __init__.py
│   │   │   ├── Login.py
│   │   │   ├── Logout.py
│   │   │   └── __pycache__
│   │   │       ├── __init__.cpython-310.pyc
│   │   │       └── Login.cpython-310.pyc
│   │   ├── Base.py
│   │   ├── Dashboard
│   │   │   ├── Dashboard.py
│   │   │   ├── __init__.py
│   │   │   └── __pycache__
│   │   │       ├── Dashboard.cpython-310.pyc
│   │   │       └── __init__.cpython-310.pyc
│   │   ├── GeneralSettings
│   │   │   ├── GeneralSettings.py
│   │   │   ├── __init__.py
│   │   │   └── __pycache__
│   │   │       ├── GeneralSettings.cpython-310.pyc
│   │   │       └── __init__.cpython-310.pyc
│   │   ├── __init__.py
│   │   ├── LoggedInPage.py
│   │   ├── Profile
│   │   │   ├── __init__.py
│   │   │   ├── InternetcashSection.py
│   │   │   ├── MyProfileSection.py
│   │   │   └── __pycache__
│   │   │       ├── __init__.cpython-310.pyc
│   │   │       ├── InternetcashSection.cpython-310.pyc
│   │   │       └── MyProfileSection.cpython-310.pyc
│   │   └── __pycache__
│   │       ├── Base.cpython-310.pyc
│   │       ├── __init__.cpython-310.pyc
│   │       └── LoggedInPage.cpython-310.pyc
│   ├── __pycache__
│   │   └── __init__.cpython-310.pyc
│   └── TestCases
│       ├── Authentication
│       │   ├── __init__.py
│       │   └── LoginTests
│       │       └── __init__.py
│       └── __init__.py
├── setup.py
└── Utilities
   ├── APIUtils
   │   ├── APIWrappers.py
   │   ├── __init__.py
   │   ├── InsensitiveRoutes.py
   │   ├── __pycache__
   │   │   ├── APIWrappers.cpython-310.pyc
   │   │   ├── __init__.cpython-310.pyc
   │   │   ├── InsensitiveRoutes.cpython-310.pyc
   │   │   └── test_logging_wrapper.cpython-310.pyc
   │   └── test_logging_wrapper.py
   ├── GeneralUtils
   │   ├── CustomExceptionHandler.py
   │   ├── __init__.py
   │   ├── __pycache__
   │   │   ├── CustomExceptionHandler.cpython-310.pyc
   │   │   ├── __init__.cpython-310.pyc
   │   │   └── StringManipulators.cpython-310.pyc
   │   └── StringManipulators.py
   ├── __init__.py
   ├── Logging
   │   ├── CustomLoggerHelper.py
   │   ├── CustomLogger.py
   │   ├── __init__.py
   │   ├── __pycache__
   │   │   ├── CustomLogger.cpython-310.pyc
   │   │   ├── CustomLoggerHelper.cpython-310.pyc
   │   │   └── __init__.cpython-310.pyc
   │   ├── test_custom_logger_2.py
   │   └── test_custom_logger.py
   ├── __pycache__
   │   └── __init__.cpython-310.pyc
   └── SeleUtils
       ├── DriverManager.py
       ├── EnvironmentSelector.py
       ├── FindElementsByText.py
       ├── Helpers.py
       ├── __init__.py
       ├── __pycache__
       │   ├── DriverManager.cpython-310.pyc
       │   ├── EnvironmentSelector.cpython-310.pyc
       │   ├── FindElementsByText.cpython-310.pyc
       │   ├── Helpers.cpython-310.pyc
       │   ├── __init__.cpython-310.pyc
       │   └── Selectors.cpython-310.pyc
       ├── Selectors.py
       └── test_seleutils.py
 

I can run it from the terminal  using the following command: 

 uvicorn Fast-API-Base:app --reload

 

I have set my Run/Debug Configuration as follows:

 

But when I try to RUN it using the RUN button, I get this error : 

 

Same thing happens for DEBUG button:

 

I would be really grateful to you if you could help me setup my FastAPI project to be RUN and DEBUGGED using PyCharm.

 

Thank you for your time!

 

0
2 comments

This is the contents of the Fast-API-Base.py file:

from fastapi import FastAPI
from Controllers.Documentation import GetEndpoints, Authentication
from Controllers.Authentication import Login, Logout
from Utilities.APIUtils.InsensitiveRoutes import CaseInsensitiveRouter
from Utilities.Logging.CustomLoggerHelper import log_message, start, ender
from Controllers.Tester import APIForTesting
from Controllers.Dashboard import Dashboard
from Controllers.AccountOwner import AccountOwnerList, AccountOwnerAutoLogin, AccountOwnerActivateDisableBrand
from Controllers.AccessLevel import AccessLevelList

from Routes.routes import router

# Create an instance of the FastAPI class
app = FastAPI(
    route_class=CaseInsensitiveRouter,
    debug=True,

    title="Project Wheel - Selenium Fast-API Python Automation Framework",
    version="0.0.1",
    terms_of_service="http://example.com/terms/",
    license_info={
        "name": "Apache 2.0",
        "identifier": "MIT",
    },
    contact={
        "name": "Syed Shams Elahi",
        "url": "https://github.com/ScarletMcLearn",
        "email": "GetRatulNow@gmail.com",
    },
    summary="Efficiently automate web testing with our lightweight FastAPI Selenium Python framework, streamlining test creation and execution for seamless integration into your development pipeline.",
)

from fastapi import FastAPI, Request
from fastapi.middleware.cors import CORSMiddleware
from fastapi.responses import PlainTextResponse


# Define the middleware
class LowercasePathMiddleware:
    def __init__(self, app):
        self.app = app

    async def __call__(self, scope, receive, send):
        async def _receive() -> dict:
            return await receive()

        async def _send(message) -> None:
            await send(message)

        # Convert the path to lowercase
        scope['path'] = scope['path'].lower()

        await self.app(scope, _receive, _send)


# Register the middleware
app.add_middleware(LowercasePathMiddleware)


# @log_function_execution  # TO DO
@app.get("/")
async def root():
    start(root)

    ender(root)
    return {"message": "Hello World"}


# log_message('Testyyyyyyyy 1')
app.include_router(router)
# log_message('Testyyyyyyyy 2')
0

Please sign in to leave a comment.