Skip to content

Tag: command-line

Can I run Jupyter notebook cells in commandline?

I am deploying a Python package, and I would like to run a simple test to see if all cells in my notebook will run without errors. I would like to test this via commandline as I have issues running a notebook in virtualenv. Is there are simple command-line way to test this? Note to the moderator: this questio…

NLTK: Package Errors? punkt and pickle?

Basically, I have no idea why I’m getting this error. Just to have more than an image, here is a similar message in code format. As it is more recent, the answer of this thread has already been mentioned in the message: Answer Perform the following: Then when you receive a window popup, select punkt und…

Get selected subcommand with argparse

When I use subcommands with python argparse, I can get the selected arguments. So args doesn’t contain ‘foo’. Simply writing sys.argv[1] doesn’t work because of the possible global args. How can I get the subcommand itself? Answer The very bottom of the Python docs on argparse sub-comm…

Read from File, or STDIN

I’ve written a command line utility that uses getopt for parsing arguments given on the command line. I would also like to have a filename be an optional argument, such as it is in other utilities like grep, cut etc. So, I would like it to have the following usage How can I implement the following? if a…