R
Railway2y ago
nova

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
Percy
Percy2y ago
Project ID: e4949be4-03c7-44a7-a413-32ffc2e9c2f7
nova
novaOP2y ago
e4949be4-03c7-44a7-a413-32ffc2e9c2f7
Brody
Brody2y ago
is the required module in your requirements.txt file?
nova
novaOP2y ago
the required module is actually my own module, but in a different directory
Brody
Brody2y ago
then just use relative paths
nova
novaOP2y ago
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 railway
Brody
Brody2y ago
definitely shouldn't be doing this, even locally again, use relative paths
nova
novaOP2y ago
is there any way to do it with absolute paths?
Brody
Brody2y ago
the word "relative" comes to mind
nova
novaOP2y ago
@Brody
Brody
Brody2y ago
#🛂|readme #5
nova
novaOP2y ago
my bad sorry
nova
novaOP2y ago
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.
Want results from more Discord servers?
Add your server