How to figure out what my PYTHONPATH environment variable should be
I am getting a
ModuleNotFoundError: No module named
. I do not have this problem when running the applicaiton through Pycharm or through the terminal. I believe I have it in railway, because the sys.path on Railway is different from that on my own machine. How do I figure out the directory dtructure in a deployed railway application so I can modify the PYTHONPATH environment variable in Railway.13 Replies
Project ID:
e4949be4-03c7-44a7-a413-32ffc2e9c2f7
e4949be4-03c7-44a7-a413-32ffc2e9c2f7
is the required module in your requirements.txt file?
the required module is actually my own module, but in a different directory
then just use relative paths
My Project/
├─ utils/
│ ├─ new_file3.py
│ ├─ new_file2.py
│ ├─ new_file.py
├─ Fast API/
│ ├─ main.py
Imagien this is my directory structure
I want to be able to import new_file into my main app
it works on my machine if I add
my project
to sys.path
but not on railwaydefinitely shouldn't be doing this, even locally
again, use relative paths
is there any way to do it with absolute paths?
the word "relative" comes to mind
@Brody
#🛂|readme #5
my bad sorry
btw for anyone looking at this in the future with the same error what I did instead was to set the project root as the outermost directory and use the following "start command"
uvicorn api.fast_api.main:app --reload --host 0.0.0.0 --port $PORT
I didn't know that you can run a uvicorn application similar to how you run a python module with the .
syntax
This allowed me to continue to use absolute imports as I was getting errors with relative imports.