You are asking for a script to be installed named standardiser.py
; that script (at least, the one you've uploaded to the cheese shop) contains the line:
from standardiser import standardise, SDF
But thats an ambigious import; the script you're executing, /usr/local/bin/standardise.py
appears in sys.path, because the main script is located there. it's importing itself!
you should be using the console_scripts
feature of setuptools anyway.
alter your script file from
#! /guess/path/to python
from standardise import import *
do_things()
do_more_things()
to
from __future__ import absolute_import
from standardise import import *
def main():
do_things()
do_more_things()
if __name__ == '__main__':
main()
Which is to say;
- get rid of the shebang; you never need it in python!
- use the
absolute_import
feature to get the module namedfoo.bar.foo
to be able to importfoo
instead of onlyfoo.bar.foo
(you can still importfoo.bar.foo
as eitherfrom foo.bar import foo
orimport .foo
).__future__
imports must appear first in the source file, before any other non-comment lines (including other imports) - most importantly; wrap import time side effects in a function, and only invoke those side effects if this is the "main script"
then change your setup.py
around from
setup(
scripts=['standardiser/bin/standardiser.py'],
...)
to
setup(
entry_points={
'console_scripts': [
'standardiser=standardiser.bin.standardiser:main']},
...)
which is to say:
- use an entry point; setuptools knows how to get your installed package on
sys.path
correctly in this case, and it knows how to connect to the proper python interpreter, the one that was used to runsetup.py
. This matters when there are multiple versions of python, or when running in a virtualenv. this is why you never need a shebang. - remove the '.py' from the installed executable name. this shouldn't ever be there for scripts that are to be on your executable path.