command-line

Can I run Jupyter notebook cells in commandline?

Can I run Jupyter notebook cells in commandline? Question: 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 …

Total answers: 3

Argparse with two values for one argument

Argparse with two values for one argument Question: Now my script calls via: python resylter.py -n *newfile* -o *oldfile* code looks like: parser.add_argument(‘-n’, ‘–newfile’, help=’Uses only with -o argument. Compares inputed OLD (-o) file with previous run results with NEW(-n) output.xml file with actual run results’) parser.add_argument(‘-o’, ‘–oldfile’, help=’Uses only with -n argument. Compares inputed …

Total answers: 2

Change Python interactive prompt ">>>"

Change Python interactive prompt ">>>" Question: I recall reading, in the Python 3.5 docs, how to change the >>> on the Python interactive prompt, such as how calling help() will change it to help>. But for some reason, when I’ve gone back to try and remember, I just can’t find the instructions to it. Does …

Total answers: 3

Install Anaconda on Ubuntu (or Linux) via command line

Install Anaconda on Ubuntu (or Linux) via command line Question: I would like to install Anaconda on a remote server. The server is running Ubuntu 12.04. I only have access to this server via SSH. How can I install Anaconda via the command line? Asked By: JNevens || Source Answers: Something along the lines of: …

Total answers: 7

How do I make a python script executable?

How do I make a python script executable? Question: How can I run a python script with my own command line name like myscript without having to do python myscript.py in the terminal? Asked By: ctrlz || Source Answers: Add a shebang line to the top of the script: #!/usr/bin/env python Mark the script as …

Total answers: 6

Creating a Python script that runs as a Windows service using sc.exe

Creating a Python script that runs as a Windows service using sc.exe Question: I would like to create a Windows Service using a batch script for a Python script that I have written. I decided to do some experimenting with sc. Here is the line that I used: sc create RoundTripService binPath=”C:Python27python.exe C:script.py” type=own error=ignore …

Total answers: 1

Launch Pycharm from command line (terminal)

Launch Pycharm from command line (terminal) Question: I want to try out PyCharm for sage mathematics development. Normally I run eclipse to do sage development, but now I want to try it with PyCharm. To launch eclipse with sage environment variables, in command line I normally do the following: sage -sh cd /path/to/eclipse ./eclipse The …

Total answers: 21

In Python, get the output of system command as a string

In Python, get the output of system command as a string Question: In python I can run some system command using os or subprocess. The problem is that I can’t get the output as a string. For example: >>> tmp = os.system("ls") file1 file2 >>> tmp 0 I have an older version of subprocess that …

Total answers: 1

How to switch between python 2.7 to python 3 from command line?

How to switch between python 2.7 to python 3 from command line? Question: I’m trying to find the best way to switch between the two python compilers, 2.7 to 3.3. I ran the python script from the cmd like this: python ex1.py Where do I set the “python” environment in the window’s environment variable to …

Total answers: 8