manage.py not found in virtual environment

I hope this ist just a misunderstanding and owed to my lacking knowledge on how venv works ...
when trying to migrate lists from mailman 2.1 I hit this:
(venv) mailman@arda:/etc/exim4$ python manage.py hyperkitty_import -l stammesleitung@list.poc.im /data/var/lib/mailman/archives/private/stammesleitung.mbox/stammesleitung.mbox
python: can't open file '/etc/exim4/manage.py': [Errno 2] No such file or directory
(venv) mailman@arda:/etc/exim4$ cd /opt/
(venv) mailman@arda:/opt$ find . -name manage.py
./mailman/venv/lib/python3.9/site-packages/mailman_web/manage.py
./mailman/venv/lib/python3.9/site-packages/falcon/bench/dj/manage.py
I thought, the venv should take care of finding the right module.
tnx

On Sat, Oct 15, 2022 at 11:51 AM Martin Lorenz <gitlab@member.holoclan.de> wrote:
In this case, you're telling python to run manage.py (for lack of a better language to explain). What you need to invoke is not python, but your django admin script - whatever it is called. My setup looks like this: (venv) mailman@lists:~$ ls -al /opt/mailman/mm/bin/ total 24 drwxr-xr-x 2 mailman mailman 4096 Aug 15 16:41 . drwxr-xr-x 8 mailman mailman 4096 Aug 21 12:49 .. -rwxr-xr-x 1 mailman mailman 156 Aug 15 16:41 django-admin -rwxr-xr-x 1 mailman mailman 249 Aug 15 16:41 gunicorn -rwxr-xr-x 1 mailman mailman 119 Aug 15 16:41 mailman -rwxr-xr-x 1 mailman mailman 804 Aug 15 16:41 mailman-post-update
And so my equivalent of what you want to invoke is:
/opt/mailman/mm/bin/django-admin hyperkitty_import -l list@name /var/list/archives/private/list.mbox/list.mbox
-- Best regards, Odhiambo WASHINGTON, Nairobi,KE +254 7 3200 0004/+254 7 2274 3223 "Oh, the cruft.", egrep -v '^$|^.*#' ¯\_(ツ)_/¯ :-)

Thanks for you hint.
unfortunately I still doubt that everything is working correctly in my setup. This is what I get, when trying to user django_admin:
(venv) mailman@arda:~/venv$ /opt/mailman/mm/bin/django-admin hyperkitty_import -l stammesleitung@list.poc.im /data/var/lib/mailman/archives/private/stammesleitung.mbox/stammesleitung.mbox
bash: /opt/mailman/mm/bin/django-admin: No such file or directory
(venv) mailman@arda:~/venv$ /opt/mailman/
.cache/ fulltext_index/ mm/ venv/ web/
(venv) mailman@arda:~/venv$ /opt/mailman
mailman/ mailman-2.1.39/
(venv) mailman@arda:~/venv$ /opt/mailman/mm/var/
archives/ cache/ data/ etc/ lists/ locks/ logs/ messages/ queue/ templates/
(venv) mailman@arda:~/venv$ /opt/mailman/mm/var/
archives/ cache/ data/ etc/ lists/ locks/ logs/ messages/ queue/ templates/
(venv) mailman@arda:~/venv$ find /opt -name django-admin
/opt/mailman/venv/bin/django-admin
(venv) mailman@arda:~/venv$ bin
bin/ bind
(venv) mailman@arda:~/venv$ bin/django-admin hyperkitty_import -l stammesleitung@list.poc.im /data/var/lib/mailman/archives/private/stammesleitung.mbox/stammesleitung.mbox
No Django settings specified.
Unknown command: 'hyperkitty_import'
Type 'django-admin help' for usage.
(venv) mailman@arda:~/venv$ bin/django-admin help
Type 'django-admin help <subcommand>' for help on a specific subcommand.
Available subcommands:
[django]
check
compilemessages
createcachetable
dbshell
diffsettings
dumpdata
flush
inspectdb
loaddata
makemessages
makemigrations
migrate
runserver
sendtestemail
shell
showmigrations
sqlflush
sqlmigrate
sqlsequencereset
squashmigrations
startapp
startproject
test
testserver
Note that only Django core commands are listed as settings are not properly configured (error: Requested setting INSTALLED_APPS, but settings are not configured. You must either define the environment variable DJANGO_SETTINGS_MODULE or call settings.
configure() before accessing settings.).

On Sat, Oct 15, 2022 at 1:47 PM Martin Lorenz <gitlab@member.holoclan.de> wrote:
I did not literally mean that you should run the command I gave :) Rather it was a pointer to what you needed to consider. As you can see, my installation path is different than yours so running the command literally would not work as it doesn't. It's good you found yours. Question now is - do you have settings_local.py in that setup? Mine is /opt/mailman/mm/settings_local.py
-- Best regards, Odhiambo WASHINGTON, Nairobi,KE +254 7 3200 0004/+254 7 2274 3223 "Oh, the cruft.", egrep -v '^$|^.*#' ¯\_(ツ)_/¯ :-)

I've got a settings.py
(according to the docs this should be the master file including settings_local.py
...) reading as follows:
root@arda:/etc/mailman3# cat settings.py
# Mailman Web configuration file.
# /etc/mailman3/settings.py
from mailman_web.settings.base import *
from mailman_web.settings.mailman import *
#: Default list of admins who receive the emails from error logging.
ADMINS = (
('Mailman Suite Admin', 'root@localhost'),
)
# Postgresql database setup.
DATABASES = {
'default': {
'ENGINE': 'django.db.backends.postgresql_psycopg2',
'NAME': 'mailmanweb',
'USER': 'mailman',
# TODO: Replace this with the password.
'PASSWORD': 'XXXXXXXXXXXXXXXXXX',
'HOST': 'localhost',
'PORT': '5432',
}
}
# 'collectstatic' command will copy all the static files here.
# Alias this location from your webserver to `/static`
STATIC_ROOT = '/opt/mailman/web/static'
# Make sure that this directory is created or Django will fail on start.
LOGGING['handlers']['file']['filename'] = '/opt/mailman/web/logs/mailmanweb.log'
#: See https://docs.djangoproject.com/en/dev/ref/settings/#allowed-hosts
ALLOWED_HOSTS = [
"localhost", # Archiving API from Mailman, keep it.
"127.0.0.1",
"list.holoclan.de",
"list.poc.im",
"list.lorenz.im"
# Add here all production domains you have.
]
#: Current Django Site being served. This is used to customize the web host
#: being used to serve the current website. For more details about Django
#: site, see: https://docs.djangoproject.com/en/dev/ref/contrib/sites/
SITE_ID = 1
# Set this to a new secret value.
SECRET_KEY = 'XXXXXXXXXXXXXXXXXX'
# Set this to match the api_key setting in
# /opt/mailman/mm/mailman-hyperkitty.cfg (quoted here, not there).
MAILMAN_ARCHIVER_KEY = 'XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX'
# The sender of emails from Django such as address confirmation requests.
# Set this to a valid email address.
DEFAULT_FROM_EMAIL = 'mailman@list.poc.im'
# The sender of error messages from Django. Set this to a valid email
# address.
SERVER_EMAIL = 'django@poc.im'

On Sat, Oct 15, 2022 at 2:14 PM Martin Lorenz <gitlab@member.holoclan.de> wrote:
I've got a
settings.py
(according to the docs this should be the master file includingsettings_local.py
...) reading as follows:
The documentation says that you should have settings.py and inside it, you ensure that DEBUG = False. Then you should have a settings_local.py which is more of a replica of settings.py and all your customizations should be done inside settings_local.py.
-- Best regards, Odhiambo WASHINGTON, Nairobi,KE +254 7 3200 0004/+254 7 2274 3223 "Oh, the cruft.", egrep -v '^$|^.*#' ¯\_(ツ)_/¯ :-)

This is the instruction I followed
https://docs.mailman3.org/en/latest/install/virtualenv.html#initial-configur...
I really don't care much about beauty at the moment. I simply need a working system.

python manage.py hyperkitty_import -l stamm ...
btw. this is, what it says in the docs: https://docs.mailman3.org/en/latest/migration.html

On Sat, Oct 15, 2022 at 2:00 PM Martin Lorenz <gitlab@member.holoclan.de> wrote:
True, and to be honest, I also found those documentations a bit confusing.
-- Best regards, Odhiambo WASHINGTON, Nairobi,KE +254 7 3200 0004/+254 7 2274 3223 "Oh, the cruft.", egrep -v '^$|^.*#' ¯\_(ツ)_/¯ :-)

https://docs.mailman3.org/en/latest/django-primer.html gives a bunch of commands but none of them works in my setup.
I followed the instructions given in https://docs.mailman3.org/en/latest/install/virtualenv.html to end with a **working** mailman3. Butt almost all the admin cli commands don't work for me.
I am amazed by the readiness to help all of you show. On the downside I would never be able to solve all the issues I get without it.
(venv) mailman@arda:~$ django-admin --settings settings --pythonpath /etc/mailman3/ test
No Django settings specified.
Unknown command: '--settings'. Did you mean diffsettings?
Type 'django-admin help' for usage.
I am not an experienced python programmer ... mailman2.1 was much easier to set up.

On Sat, Oct 15, 2022 at 2:38 PM Martin Lorenz <gitlab@member.holoclan.de> wrote:
Please craft a settings_local.py. Feel free to pick mine <https://pastebin.ubuntu.com/p/fJMBmhfWFH/> and edit as needed.
I am not an experienced python programmer ... mailman2.1 was much easier to set up.
You need a dose of chill pill with MM3. You are still far away from getting done :-)
-- Best regards, Odhiambo WASHINGTON, Nairobi,KE +254 7 3200 0004/+254 7 2274 3223 "Oh, the cruft.", egrep -v '^$|^.*#' ¯\_(ツ)_/¯ :-)

Odhiambo Washington wrote:
You need a dose of chill pill with MM3. You are still far away from getting done :-)
I don't have the **time** to spend on that. It already took me two full days of reading docs and asking questions. I have more urgent things to do, but there are quite a few people who got used to the mailinglists I am hosting for over a decade now.

Martin Lorenz writes:
python manage.py hyperkitty_import -l stamm ...
btw. this is, what it says in the docs: https://docs.mailman3.org/en/latest/migration.html
I assume you're just pip'ing everything from PyPI, without any version constraints on the command line? If yes, good, that's what I need to know. If not, what versions of Mailman 3 applications are you installing, from what source?
I suspect those docs predate the creation of mailman-web. Instead of running "python manage.py hyperkitty_import ...", make sure your venv is activated and run "mailman-web hyperkitty_import ...". You still use the "mailman" command to import list configurations (such as subscriber lists and their profiles) from Mailman 2 to Mailman 3, but you use "mailman-web" for importing list archives (past messages).
To test if you have your settings.py in the right place, make sure your venv is activated and run "mailman-web help | less". If everything is in the right places that will produce a (long) list of commands that you can use, including hyperkitty_import.
I don't think you actually need settings_local.py since we introduced mailman-web.
If you are following the virtualenv install instructions, you need to put mailman.cfg and settings.py in /etc/mailman3 (or you can set MAILMAN_WEB_CONFIG to point to the right settings.py). This is also where you should usually put configuration files for WSGI providers like gunicorn or uwsgi, and possibly some webserver-related files.
Steve

seems to me, you are right:
(venv) mailman@arda:~$ mailman-web help
[...]
[hyperkitty]
hyperkitty_import
hyperkitty_warm_up_cache
mailman_sync
update_index_one_list
[...]
I followed the instructions:
using pip to get mailman and deps
basis is a debian bullseye with python 3.9
I just added one version constraint, because Mark told me to when I hit a bug during installation:
mistune==2.0.0rc1
Yes, my settings live in /etc/mailman3

Worked like a charm:
for l in <list of all old mailinglists for domain list.poc.im> ; do list=${l}@list.poc.im; d=/data/var/lib/mailman/lists/${l}; echo $list; mailman-web hyperkitty_import -l $list /data/var/lib/mailman/archives/private/$ {l}.mbox/${l}.mbox; done
did the same for two more domains and ran mailman-web rebuild_index
afterwards.
Now all seems good
Thank you all for your help! Thank you Washington for the insights into your config. I learned a lot!

Martin Lorenz writes:
(venv) mailman@arda:/etc/exim4$ python manage.py hyperkitty_import -l stammesleitung@list.poc.im /data/var/lib/mailman/archives/private/stammesleitung.mbox/stammesleitung.mbox
Executive summary: you have to specify an absolute or relative path to manage.py.
Here's why. When invoked as "python manage.py ..." it is treated as an ordinary file argument (that happens to be a Python script), and is not searched for on Python's sys.path or on the shell's PATH.
When invoked as "python -m manage ..." it is treated as a module, and searched for on sys.path. But don't do this, there are differences between "python foo.py" and "python -m foo", and manage.py is not designed to be invoked with "-m". Also, the same Django installation may support a variety of applications each of which has its own manage.py, and there's no reason to suppose the one that's first on sys.path is the one you want unless you are already cd'ed to manage.py's directory. For example, before the creation of Mailman web, both HyperKitty and Postorius had their own manage.py. In fact, in some applications manage.py may not be on sys.path at all (unless it's in the current working directory).
Steve

On Sat, Oct 15, 2022 at 11:51 AM Martin Lorenz <gitlab@member.holoclan.de> wrote:
In this case, you're telling python to run manage.py (for lack of a better language to explain). What you need to invoke is not python, but your django admin script - whatever it is called. My setup looks like this: (venv) mailman@lists:~$ ls -al /opt/mailman/mm/bin/ total 24 drwxr-xr-x 2 mailman mailman 4096 Aug 15 16:41 . drwxr-xr-x 8 mailman mailman 4096 Aug 21 12:49 .. -rwxr-xr-x 1 mailman mailman 156 Aug 15 16:41 django-admin -rwxr-xr-x 1 mailman mailman 249 Aug 15 16:41 gunicorn -rwxr-xr-x 1 mailman mailman 119 Aug 15 16:41 mailman -rwxr-xr-x 1 mailman mailman 804 Aug 15 16:41 mailman-post-update
And so my equivalent of what you want to invoke is:
/opt/mailman/mm/bin/django-admin hyperkitty_import -l list@name /var/list/archives/private/list.mbox/list.mbox
-- Best regards, Odhiambo WASHINGTON, Nairobi,KE +254 7 3200 0004/+254 7 2274 3223 "Oh, the cruft.", egrep -v '^$|^.*#' ¯\_(ツ)_/¯ :-)

Thanks for you hint.
unfortunately I still doubt that everything is working correctly in my setup. This is what I get, when trying to user django_admin:
(venv) mailman@arda:~/venv$ /opt/mailman/mm/bin/django-admin hyperkitty_import -l stammesleitung@list.poc.im /data/var/lib/mailman/archives/private/stammesleitung.mbox/stammesleitung.mbox
bash: /opt/mailman/mm/bin/django-admin: No such file or directory
(venv) mailman@arda:~/venv$ /opt/mailman/
.cache/ fulltext_index/ mm/ venv/ web/
(venv) mailman@arda:~/venv$ /opt/mailman
mailman/ mailman-2.1.39/
(venv) mailman@arda:~/venv$ /opt/mailman/mm/var/
archives/ cache/ data/ etc/ lists/ locks/ logs/ messages/ queue/ templates/
(venv) mailman@arda:~/venv$ /opt/mailman/mm/var/
archives/ cache/ data/ etc/ lists/ locks/ logs/ messages/ queue/ templates/
(venv) mailman@arda:~/venv$ find /opt -name django-admin
/opt/mailman/venv/bin/django-admin
(venv) mailman@arda:~/venv$ bin
bin/ bind
(venv) mailman@arda:~/venv$ bin/django-admin hyperkitty_import -l stammesleitung@list.poc.im /data/var/lib/mailman/archives/private/stammesleitung.mbox/stammesleitung.mbox
No Django settings specified.
Unknown command: 'hyperkitty_import'
Type 'django-admin help' for usage.
(venv) mailman@arda:~/venv$ bin/django-admin help
Type 'django-admin help <subcommand>' for help on a specific subcommand.
Available subcommands:
[django]
check
compilemessages
createcachetable
dbshell
diffsettings
dumpdata
flush
inspectdb
loaddata
makemessages
makemigrations
migrate
runserver
sendtestemail
shell
showmigrations
sqlflush
sqlmigrate
sqlsequencereset
squashmigrations
startapp
startproject
test
testserver
Note that only Django core commands are listed as settings are not properly configured (error: Requested setting INSTALLED_APPS, but settings are not configured. You must either define the environment variable DJANGO_SETTINGS_MODULE or call settings.
configure() before accessing settings.).

On Sat, Oct 15, 2022 at 1:47 PM Martin Lorenz <gitlab@member.holoclan.de> wrote:
I did not literally mean that you should run the command I gave :) Rather it was a pointer to what you needed to consider. As you can see, my installation path is different than yours so running the command literally would not work as it doesn't. It's good you found yours. Question now is - do you have settings_local.py in that setup? Mine is /opt/mailman/mm/settings_local.py
-- Best regards, Odhiambo WASHINGTON, Nairobi,KE +254 7 3200 0004/+254 7 2274 3223 "Oh, the cruft.", egrep -v '^$|^.*#' ¯\_(ツ)_/¯ :-)

I've got a settings.py
(according to the docs this should be the master file including settings_local.py
...) reading as follows:
root@arda:/etc/mailman3# cat settings.py
# Mailman Web configuration file.
# /etc/mailman3/settings.py
from mailman_web.settings.base import *
from mailman_web.settings.mailman import *
#: Default list of admins who receive the emails from error logging.
ADMINS = (
('Mailman Suite Admin', 'root@localhost'),
)
# Postgresql database setup.
DATABASES = {
'default': {
'ENGINE': 'django.db.backends.postgresql_psycopg2',
'NAME': 'mailmanweb',
'USER': 'mailman',
# TODO: Replace this with the password.
'PASSWORD': 'XXXXXXXXXXXXXXXXXX',
'HOST': 'localhost',
'PORT': '5432',
}
}
# 'collectstatic' command will copy all the static files here.
# Alias this location from your webserver to `/static`
STATIC_ROOT = '/opt/mailman/web/static'
# Make sure that this directory is created or Django will fail on start.
LOGGING['handlers']['file']['filename'] = '/opt/mailman/web/logs/mailmanweb.log'
#: See https://docs.djangoproject.com/en/dev/ref/settings/#allowed-hosts
ALLOWED_HOSTS = [
"localhost", # Archiving API from Mailman, keep it.
"127.0.0.1",
"list.holoclan.de",
"list.poc.im",
"list.lorenz.im"
# Add here all production domains you have.
]
#: Current Django Site being served. This is used to customize the web host
#: being used to serve the current website. For more details about Django
#: site, see: https://docs.djangoproject.com/en/dev/ref/contrib/sites/
SITE_ID = 1
# Set this to a new secret value.
SECRET_KEY = 'XXXXXXXXXXXXXXXXXX'
# Set this to match the api_key setting in
# /opt/mailman/mm/mailman-hyperkitty.cfg (quoted here, not there).
MAILMAN_ARCHIVER_KEY = 'XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX'
# The sender of emails from Django such as address confirmation requests.
# Set this to a valid email address.
DEFAULT_FROM_EMAIL = 'mailman@list.poc.im'
# The sender of error messages from Django. Set this to a valid email
# address.
SERVER_EMAIL = 'django@poc.im'

On Sat, Oct 15, 2022 at 2:14 PM Martin Lorenz <gitlab@member.holoclan.de> wrote:
I've got a
settings.py
(according to the docs this should be the master file includingsettings_local.py
...) reading as follows:
The documentation says that you should have settings.py and inside it, you ensure that DEBUG = False. Then you should have a settings_local.py which is more of a replica of settings.py and all your customizations should be done inside settings_local.py.
-- Best regards, Odhiambo WASHINGTON, Nairobi,KE +254 7 3200 0004/+254 7 2274 3223 "Oh, the cruft.", egrep -v '^$|^.*#' ¯\_(ツ)_/¯ :-)

This is the instruction I followed
https://docs.mailman3.org/en/latest/install/virtualenv.html#initial-configur...
I really don't care much about beauty at the moment. I simply need a working system.

python manage.py hyperkitty_import -l stamm ...
btw. this is, what it says in the docs: https://docs.mailman3.org/en/latest/migration.html

On Sat, Oct 15, 2022 at 2:00 PM Martin Lorenz <gitlab@member.holoclan.de> wrote:
True, and to be honest, I also found those documentations a bit confusing.
-- Best regards, Odhiambo WASHINGTON, Nairobi,KE +254 7 3200 0004/+254 7 2274 3223 "Oh, the cruft.", egrep -v '^$|^.*#' ¯\_(ツ)_/¯ :-)

https://docs.mailman3.org/en/latest/django-primer.html gives a bunch of commands but none of them works in my setup.
I followed the instructions given in https://docs.mailman3.org/en/latest/install/virtualenv.html to end with a **working** mailman3. Butt almost all the admin cli commands don't work for me.
I am amazed by the readiness to help all of you show. On the downside I would never be able to solve all the issues I get without it.
(venv) mailman@arda:~$ django-admin --settings settings --pythonpath /etc/mailman3/ test
No Django settings specified.
Unknown command: '--settings'. Did you mean diffsettings?
Type 'django-admin help' for usage.
I am not an experienced python programmer ... mailman2.1 was much easier to set up.

On Sat, Oct 15, 2022 at 2:38 PM Martin Lorenz <gitlab@member.holoclan.de> wrote:
Please craft a settings_local.py. Feel free to pick mine <https://pastebin.ubuntu.com/p/fJMBmhfWFH/> and edit as needed.
I am not an experienced python programmer ... mailman2.1 was much easier to set up.
You need a dose of chill pill with MM3. You are still far away from getting done :-)
-- Best regards, Odhiambo WASHINGTON, Nairobi,KE +254 7 3200 0004/+254 7 2274 3223 "Oh, the cruft.", egrep -v '^$|^.*#' ¯\_(ツ)_/¯ :-)

Odhiambo Washington wrote:
You need a dose of chill pill with MM3. You are still far away from getting done :-)
I don't have the **time** to spend on that. It already took me two full days of reading docs and asking questions. I have more urgent things to do, but there are quite a few people who got used to the mailinglists I am hosting for over a decade now.

Martin Lorenz writes:
python manage.py hyperkitty_import -l stamm ...
btw. this is, what it says in the docs: https://docs.mailman3.org/en/latest/migration.html
I assume you're just pip'ing everything from PyPI, without any version constraints on the command line? If yes, good, that's what I need to know. If not, what versions of Mailman 3 applications are you installing, from what source?
I suspect those docs predate the creation of mailman-web. Instead of running "python manage.py hyperkitty_import ...", make sure your venv is activated and run "mailman-web hyperkitty_import ...". You still use the "mailman" command to import list configurations (such as subscriber lists and their profiles) from Mailman 2 to Mailman 3, but you use "mailman-web" for importing list archives (past messages).
To test if you have your settings.py in the right place, make sure your venv is activated and run "mailman-web help | less". If everything is in the right places that will produce a (long) list of commands that you can use, including hyperkitty_import.
I don't think you actually need settings_local.py since we introduced mailman-web.
If you are following the virtualenv install instructions, you need to put mailman.cfg and settings.py in /etc/mailman3 (or you can set MAILMAN_WEB_CONFIG to point to the right settings.py). This is also where you should usually put configuration files for WSGI providers like gunicorn or uwsgi, and possibly some webserver-related files.
Steve

seems to me, you are right:
(venv) mailman@arda:~$ mailman-web help
[...]
[hyperkitty]
hyperkitty_import
hyperkitty_warm_up_cache
mailman_sync
update_index_one_list
[...]
I followed the instructions:
using pip to get mailman and deps
basis is a debian bullseye with python 3.9
I just added one version constraint, because Mark told me to when I hit a bug during installation:
mistune==2.0.0rc1
Yes, my settings live in /etc/mailman3

Worked like a charm:
for l in <list of all old mailinglists for domain list.poc.im> ; do list=${l}@list.poc.im; d=/data/var/lib/mailman/lists/${l}; echo $list; mailman-web hyperkitty_import -l $list /data/var/lib/mailman/archives/private/$ {l}.mbox/${l}.mbox; done
did the same for two more domains and ran mailman-web rebuild_index
afterwards.
Now all seems good
Thank you all for your help! Thank you Washington for the insights into your config. I learned a lot!

Martin Lorenz writes:
(venv) mailman@arda:/etc/exim4$ python manage.py hyperkitty_import -l stammesleitung@list.poc.im /data/var/lib/mailman/archives/private/stammesleitung.mbox/stammesleitung.mbox
Executive summary: you have to specify an absolute or relative path to manage.py.
Here's why. When invoked as "python manage.py ..." it is treated as an ordinary file argument (that happens to be a Python script), and is not searched for on Python's sys.path or on the shell's PATH.
When invoked as "python -m manage ..." it is treated as a module, and searched for on sys.path. But don't do this, there are differences between "python foo.py" and "python -m foo", and manage.py is not designed to be invoked with "-m". Also, the same Django installation may support a variety of applications each of which has its own manage.py, and there's no reason to suppose the one that's first on sys.path is the one you want unless you are already cd'ed to manage.py's directory. For example, before the creation of Mailman web, both HyperKitty and Postorius had their own manage.py. In fact, in some applications manage.py may not be on sys.path at all (unless it's in the current working directory).
Steve
participants (3)
-
Martin Lorenz
-
Odhiambo Washington
-
Stephen J. Turnbull