FastAPI + Uvicorn Run Configuration won't work

Hey guys, I am having trouble since this morning to run a FastAPI project in PyCharm, it's returning a null pointer while trying to run the configuration:

2024-12-11 11:08:55,553 [3196583]   INFO - #c.i.e.r.ExecutionUtil - Error running 'Start':<br>Unknown error
java.lang.NullPointerException
    at com.intellij.python.pro.fastapi.FastApiRunServerCommandLineState._get_uvicornAppName_$lambda$2(fastApiRun.kt:99)
    at com.intellij.openapi.application.impl.RwLockHolder.runReadAction(RwLockHolder.kt:289)
    at com.intellij.openapi.application.impl.ApplicationImpl.runReadAction(ApplicationImpl.java:850)
    at com.intellij.openapi.application.ReadAction.compute(ReadAction.java:65)
    at com.intellij.python.pro.fastapi.FastApiRunServerCommandLineState.getUvicornAppName(fastApiRun.kt:92)
    at com.intellij.python.pro.fastapi.FastApiRunServerCommandLineState.buildPythonExecution(fastApiRun.kt:136)
    at com.jetbrains.python.run.PythonCommandLineState.buildPythonExecutionFinal(PythonCommandLineState.java:367)
    at com.jetbrains.python.run.PythonCommandLineState.startProcess(PythonCommandLineState.java:331)
    at com.jetbrains.python.run.PythonCommandLineState.execute(PythonCommandLineState.java:238)
    at com.jetbrains.python.debugger.PyDebugRunner.lambda$createSessionUsingTargetsApi$2(PyDebugRunner.java:181)
    at org.jetbrains.concurrency.Promises__PromiseKt$runAsync$1.run(promise.kt:214)
    at com.intellij.util.concurrency.ContextRunnable.run(ContextRunnable.java:27)
    at java.base/java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1136)
    at java.base/java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:635)
    at java.base/java.util.concurrent.Executors$PrivilegedThreadFactory$1$1.run(Executors.java:702)
    at java.base/java.util.concurrent.Executors$PrivilegedThreadFactory$1$1.run(Executors.java:699)
    at java.base/java.security.AccessController.doPrivileged(AccessController.java:399)
    at java.base/java.util.concurrent.Executors$PrivilegedThreadFactory$1.run(Executors.java:699)
    at java.base/java.lang.Thread.run(Thread.java:840)

 

Edit:

OS: Mac Apple M1 Pro
Version: Sonoma 14.7.1
PyCharm Version: PyCharm 2024.1.7 (Professional Edition)

0
2 comments

Update: I have absolutely no idea what the problem was. I tried deleting the cache and closing/restarting the IDE and nothing fixed it.

Then I decided to close the project and open it again (I have some other projects open there) and that fixed it.

Bamboozled here

0
Hello,
If you had hyphens in your main script name, then it is this issue: https://youtrack.jetbrains.com/issue/PY-71300/Hyphen-in-the-FastAPI-main-script-name-leads-to-a-null-pointer-exception
Otherwise, most likely it was either a fluke or specific sourcing of the local packages: https://youtrack.jetbrains.com/issue/PY-61236/Unable-to-run-FastAPI-uvicorn-app-on-Intellij-Unknown-error
If you encounter the issue again, please create a new issue in the PyCharm branch of YouTrack, so we can properly process it.
0

Please sign in to leave a comment.