3

can anyone help us with this problem I am trying to deploy Django application on the railway but got an error /bin/bash: line 1: gunicorn: command not found

my gunicorn path

/usr/local/lib/python3.10/dist-packages

python path

['', '/usr/lib/python310.zip', '/usr/lib/python3.10', '/usr/lib/python3.10/lib-dynload', '/root/.local/lib/python3.10/site-packages', '/usr/local/lib/python3.10/dist-packages', '/usr/local/lib/python3.10/dist-packages/drupwn-1.0.3-py3.10.egg', '/usr/local/lib/python3.10/dist-packages/prompt_toolkit-2.0.7-py3.10.egg', '/root/droopescan', '/usr/lib/python3/dist-packages', '/usr/lib/python3.10/dist-packages']

I tried to add a path but I am not able to do it. Can anyone please help me to solve this problem?

9
  • PYTHONPATH doesn't matter here. Please provide the output of echo $PATH from a bash session owned by the same user. Otherwise, you have two options: 1) add /usr/local/lib/python3.10/dist-packages to PATH, or 2) change the command to start gunicorn to use the fully qualified path /usr/local/lib/python3.10/dist-packages/gunicorn. Commented Dec 1, 2022 at 17:38
  • echo $PATH /usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/local/games:/usr/games Commented Dec 1, 2022 at 17:56
  • There you go. The gunicorn executable's path isn't in the PATH environment variable. Commented Dec 1, 2022 at 18:05
  • can you please tell me how to add gunicorn executable's path to the PATH environment variable? Commented Dec 1, 2022 at 18:07
  • PATH=$PATH:/usr/local/lib/python3.10/dist-packages. Depending on how the environment and execution are set up, you may need export PATH=$PATH:/usr/local/lib/python3.10/dist-packages. Commented Dec 1, 2022 at 18:11

1 Answer 1

2

I'm 6 months late but this finally might be a question I can actually answer. I'm fairly new to all this and working with flask, not django, so take this all with a grain of salt

That said, I was getting the same error message trying to get a flask application deployed on Railway. Here's what solved it for me:

1.) In your IDE/virtual environment, from the terminal (if you've not done this already):

pip install gunicorn 

2.) From the terminal,

pip freeze > requirements.txt

to generate/update the requirements.txt file. Make sure gunicorn is included in it

3.) Create a file called "Procfile" in the working directory - the capitalization is important. Also, it must NOT have a file extension

4.) Within the "Procfile", include this one line of text:

web: gunicorn main:app

where "main" is the name of your main python file. So if your main file was named "asdfjkl.py", you'd put this in the Procfile:

web: gunicorn asdfjkl:app

Make sure you have the spaces set up like above

5.) Start a github repo for the project/commit the latest files to it (including requirements.txt and the Procfile)

6.) Go to railway, open a new flask app project, and link to that github repo. Should deploy successfully after that (or at least give a new error message)

I've done this now with 2 different flask apps and that seems to have solved the problem for me. Or at least gotten me to a different log error unrelated to gunicorn. Hope this helps!

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.