Closed liamrathke closed 6 years ago
You want to use a python virtual environment. You can do so using the following commands.
virtualenv --python=python3 venv
source venv/bin/activate
pip install <all your packages>
In your run.sh
, you want to put something like:
#!/bin/sh
venv/bin/python main.py
The reason for this is because the user the web server is running under is not the same as your user account. This is done for security reasons, to ensure that if your app is ever compromised nothing else on your account is affected.
OK, thanks for the help, I'll try that and report back.
@ezwang thanks for the help, I set up a virtualenv in Python 3.5 but I'm still getting the same issue. All the dependencies are installed and check out, but it can't find the first module I try and import. Maybe it's something with my file structure? I have it set up like this right now:
I also followed [https://director.tjhsst.edu/docs/dynamic-sites-on-director/](these instructions) and changed my run.sh file to match:
#!/bin/bash
source venv/bin/activate
gunicorn server:app -b 127.0.0.1:$PORT -w=4
Is this structure correct?
By default the script is run in the public
folder. You can either move your venv
folder to the public
folder, or use source ../venv/bin/activate
instead of source venv/bin/activate
.
Hope that helps!
Thanks again for the suggestions, @ezwang. Unfortunately, that was not able to fix the problem. I tried both ways, and I'm getting the same error. For now, I've moved venv
to public/venv
.
For some reason, Gunicorn can't import Eventlet, a module I'm using, so it keeps shutting down and restarting again. I can run the server fine via the Online Terminal, but it doesn't run when I use run.sh
(with Gunicorn, as per the documentation). When I remove the Gunicorn line and just run python3 server.py
in the virtual env, nothing is printed to the speedia.log
file (although I can still print to files).
Is there a way to just run everything without Gunicorn? I'm already using Flask and Eventlet, and I don't really understand why Gunicorn specifically is helpful in this instance.
Also, I must have somehow messed up somewhere else, since I'm also not able to make a domain.
Is there another domain I'm supposed to be using instead?
You should be able to run the server without gunicorn, just listen on the port specified by the PORT
environment variable. In python, you can access this through os.environ["PORT"]
.
If you want to use a custom domain that does not end with .tjhsst.edu
, you need to obtain one from somewhere like NameCheap and point it in the right place.
I've updated the domain to the correct value, you should be able to access it at speedia.sites.tjhsst.edu
.
I want to run a Python 3 app that I currently have running locally through Director, but, for some reason, it isn't reading the modules I have installed.
I'm using this in my
run.sh
:I've installed all the modules through pip3, which lists these:
and so on, with all the dependencies that I have installed locally.
However, Director gives a
FATAL Exited too quickly
error when running themain.py
file that requires some dependencies (which should be installed via pip3):Am I doing anything wrong or is there a workaround for Director?