I'm trying to run django combined with Jupyter in a virtual environment. The following code gets the job done:
source home/sujith/dev/django/bin/activate && python home/sujith/dev/django/src/manage.py shell_plus --notebook
I saved the script as django.sh
in my home directory. If I run ./django.sh
the notebook pops up.
I tried saving this in /bin
, but I couldn't run it. I want to type django
instead of ./django.sh
in my terminal and have the above script run.
How can I achieve this?
As ponsfrilus said, you must use absolute paths (paths starting with
/
) for your commands to work from/bin
or/usr/local/bin
. So your script should become:To run it as
django
, you must save your script in a file nameddjango
with#/bin/bash
on the top of the file. Then make it executable by running:where
/path/to/django
is the absolute path to your script.Finally, move your script to
/bin
by running:You should now be able to run your script just by typing
django
in your terminal.Another, much simpler, option is to create an alias for your script, by adding the following at the end of your
.bashrc
file:Then close your terminal and reopen it or run the following for the alias to take effect: