2

I've uploaded a python module to pypi and locally installed the module with:

pip install microarray_quantilenorm

I'm trying to run the module on commandline with pass-through arguments.

When I call the python script directly from site-packages, everything works fine.

python /site-packages/microarray_quantilenorm/microarray_quantilenorm.py *csv

But calling:

python -m microarray_quantilenorm.__main__ *csv

OR:

python -m microarray_quantilenorm *csv

Results in:

/anaconda/bin/python: No module named microarray_quantilenorm.__main__

I cannot track down to whether there is an issue in setup.py, my __init__.py or elsewhere. Thanks.

1 Answer 1

3

The whole point of __main__.py is that it's the file that's run when the package is run as a module. In other words, just do python -m microarray_quantilenorm, not python -m microarray_quantilenorm.__main__.

However, usually, there's an even better solution. Assuming you're using setuptools rather than trying to do the whole mess manually, use a console_scripts entry point. This will make the setup process automatically create a script named microarray_quantilenorm and install it in your bin or scripts directory that does the right thing to load the package and run its main code (or, if you prefer, some other code within it).

Sign up to request clarification or add additional context in comments.

4 Comments

Question on the syntax of console_scripts, what syntax would I use to call the script? using microarray_quantilenorm=microarray_quantilenorm:main results in error.
@user2277435: See the docs. But first, did you remember the quotes? Second, main is the name of a function to call. Does your microarray_quantilenorm.__main__ have a main function? If this isn't enough to help, I'd suggest creating a new question, where you can include details like what error it results in and exactly what you put where.
Yes, could not see which syntax to use based on docs, but it is called in setup.py with quotes. Yes, my python script contains a main function. I'll post as a separate question if I can't resolve after more time. Thank you again.
@user2277435: The docs I linked in the answer just give a minimal example, but the docs I linked in the comment (which should also be linked somewhere from the other docs, I hope) have a little more information.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.