Ask Your Question

Revision history [back]

click to hide/show revision 1
initial version

Executing python modules from package

I have a project that is primarily written in python but uses sage for some specific operations. In order to facilitate this I have only .py files and use from sage.all import * at the top of all modules that make use of sage functionalities. To execute I always used sage -python path/to/file.py.

This approach worked fine until it became necessary to split my project into multiple sub-packages. I now want to execute my modules with python -m package.subpackage.module for modules that do not use sage (which works) and correspondingly sage -python -m package.subpackage.module for modules that do. Unfortunately the latter only returns an error message of the form ~/sage/local/bin/python: No module named package.subpackage

In order to be able to use package relative imports I am kind of dependent on the -m syntax, so I would like to get it to work. Any ideas what I am doing wrong? Or is this simply not possible with the python that is bundled with sage for internal reasons? Any help is apreciated!