w3hello.com logo
Home PHP C# C++ Android Java Javascript Python IOS SQL HTML videos Categories
python installation "cc1.exe: error: unrecognized command line option '-mno-cygwin'"
See this answer: http://stackoverflow.com/a/6035864/1516291 you need to edit distutilscygwinccompiler.py in your Python directory to remove all instances of -mno-cygwin good luck

Categories : Python

Not able to install requests on cygwin - ImportError: No module named _io
It is probably because your Anti-Virus program deleted io.py. I just had to reinstall python on cygwin and try installing the program with the Anti-Virus turned off. I successfully installed request this way.

Categories : Python

Batch Command to Cygwin after Cygwin Loads
Assuming that you're using bash, appending the following line to your ${HOME}/.bashrc would achieve the desired result: cd /cygdrive/c/cygwin/home/Alex/rails_projects/demo_app/

Categories : Windows

Defining the command line arguments of a linux command in python
format is your friend: import os, sys if len(sys.argv) == 2: os.system("sudo rtcwake -m off -s {}".format(sys.argv[1])) else: print "usage: ..." so the seconds are command line parameters. Or, you can make it interactive: import os secs = raw_input() os.system("sudo rtcwake off -s {}".format(secs)) to verify that the user input is an integer: try: secs = int(secs) except: print 'usage: '

Categories : Python

Always given command line before python fabric command is executed on remote
Interesting, I don't have such issue, your code works fine for me (up to adding env.key_filename and env.password) c:work>fab hello [x.x.x.x] Executing task 'hello' [x.x.x.x] run: touch hello.world Done. Disconnecting from x.x.x.x... done. I'm using Fabric 1.7.0 and Paramiko 1.11.0. Possibly it's a problem of the terminal on your server.

Categories : Python

How to switch between python 2.7 to python 3 from command line?
For Windows 7, I just rename the python.exe from the Python 3 folder to python3.exe and add the path into the environment variables. Using that, I can execute python test_script.py and the script runs with Python 2.7 and when I do python3 test_script.py, it runs the script in Python 3. To add Python 3 to the environment variables, follow these steps - Right Click on My Computer and go to Properties. Go to Advanced System Settings. Click on Environment Variables and edit PATH and add the path to your Python 3 installation directory. For example,

Categories : Python

Getting Command line in Python
Just use sys.argv, like this: import sys # this part executes when the script is run from the command line if __name__ == '__main__': if len(sys.argv) != 2: # check for the correct number of arguments print 'usage: python kb.py cur' else: call_your_code(sys.argv[1]) # first command line argument Note: sys.argv[0] is the script's name, and sys.argv[1] is the first command line argument. And so on, if there were more arguments.

Categories : Python

Python, Command Line, Windows
After modifying your path, did you start up a new instance of the command prompt (this has caused me much grief in the past)? To check if your path change was successful: echo %PATH% and check to see if C:Python2.7.5 was appended to it. If not then run: set PATH=%PATH%;C:Python2.7.5 To call a python script with a command line argument (assuming that your script is in the current working directory): python letter_counts.py "Your Text Goes Here" OR if you just want to be overly verbose (or your PATH still isn't right): C:Python2.7.5python.exe .letter_counts.py "Your text still goes here" EDIT: Make sure you are doing this from the command prompt and not the python interpreter. To access the command prompt you can hit: 1. Windows Key + R 2. type "cmd" (without quotes) and hit

Categories : Python

Python - Need to get argument on command line
argparse is beautiful. Redesign your command line interface for it or write your own CLI-parser. CLI example: args = ['firstargument', 'secondargument', '-s', 'thirdargument', '-s', 'fourth', 'fifth', '-s', 'sixth'] last_arg = None container = [] marker = '-s' for arg in args: if (arg != marker): last_arg = arg else: container.append(last_arg) print container Result of execute: $python test.py ['secondargument', 'thirdargument', 'fifth']

Categories : Python

Run sqlite3 with python in command line
Python itself dosen't contain a sqlite3 command. But the SQLite library includes a simple command-line utility named sqlite3 (or sqlite3.exe on windows) that allows the user to manually enter and execute SQL commands against an SQLite database. You can download it from here.

Categories : Python

Flyway command line filesystem migrations from actual command line input
flyway.cmd -configFile=/path/to/other/configFile.conf should do what you want. I just checked and it seems I forgot to document this on the website (It is in the usage description of the tool itself). Could you file an issue against the website, requesting this to be added?

Categories : Windows

Complete as-you-type on command line with python
I would try with "curses" library: http://docs.python.org/2/library/curses.html You have a related topic at: How to make python autocompletion display matches?

Categories : Python

Basics of Command Line Arguments, Python
You want to use the sys.argv list from the sys module. It lets you access arguments passed in the command line. For example, if your command line input was python myfile.py a b c, sys.argv[0] is myfile.py, sys.argv[1] is a, sys.argv[2] is b, and sys.argv[3] is c. A running example (testcode.py): if __name__ == "__main__": import sys print sys.argv Then, running (in the command line): D:some_path>python testcode.py a b c ['testcode.py', 'a', 'b', 'c']

Categories : Python

How To Run A Python File From Windows Command Line
If you want to know How do I run a .py file from the Python interpreter? this will work import sys sys.path.append("C:\Users\Myname\Desktop\Python") import Python-Test But your question says from the command line, which has been answered in the comments.

Categories : Python

Run a pydev module from python or ipython or command line?
two options: 1) set $PYTHONPATH in your ~/.bash_profile. This will affect both python and ipython. 2) make ipython change the path on startup. edit your ipython startup script, very likely something like ~/.ipython/profile_default/startup/00run.ipy, and add import sys path = 'path/to/project' if not path in sys.path: sys.path.insert(1, path) del path if you are working in ipython a lot in that project, you may add %cd 'path/to/project' to the startup file as well.

Categories : Python

Hadoop mapreduce python command line arguments
You can read the input file from os.environ. For example, import os input_file = os.environ['map_input_file'] Actually, you can also read other JobConf from os.environ. Note: During the execution of a streaming job, the names of the "mapred" parameters are transformed. The dots ( . ) become underscores ( _ ). For example, mapred.job.id becomes mapred_job_id and mapred.jar becomes mapred_jar. To get the values in a streaming job's mapper/reducer use the parameter names with the underscores. See Configured Parameters. I also find a very useful post for you: A Guide to Python Frameworks for Hadoop.

Categories : Python

Execute process from the windows command line in Python
By trying your code it prints out PreprocessedTufts8199PLAIN.txt.xml file name. I'm not sure if the .txt.xml extension was the desired result. If your file has only .xml extension, then you're not stripping away the original .txt header. Try to change this line: outFile = file(inFile[(str(inFile).rfind('\'))+1:] + '.xml') Into this code: fnameext = inFile[(str(inFile).rfind('\'))+1:] fname,fext = os.path.splitext(fnameext) xmlfname = fname + '.xml' xmlfpath = os.path.join(".", xmlfname) print "xmlfname:", xmlfname, " xmlfpath:", xmlfpath print "current working directory:", os.getcwd() outFile = open(xmlfpath, "r") Answer for extension stripping.

Categories : Python

Why does python's recursive copy not work the same as on the command line?
Seems os.system changes the shell it executes in to sh: mike@mike-VirtualBox:~/head$ echo $0 bash mike@mike-VirtualBox:~/head$ python Python 2.7.3 (default, Apr 10 2013, 06:20:15) >>> import os >>> os.system("echo $0") sh When the copy command is executed via Popen with a bash shell, it works as expected: >>> import subprocess >>> sp.Popen("cp -rf ./applications/icom_app_template ./applications/my_dir", shell=True, executable="/bin/bash") >>> exit() mike@mike-VirtualBox:~/head$ tree ./applications/my_dir/ ./applications/my_dir/ ├── cdl │ ├── include │ ├── Makefile │ ... │ └── other ├── cds │ ├── include ... The only oddity that I do not have an answer for is that if I

Categories : Python

How to run python program on command line with different input possibilities
You'll have to make all arguments optional and validate them yourself: ap=argparse.ArgumentParser() ap.add_argument('-c', required=False) ap.add_argument('a', nargs='?') ap.add_argument('b', nargs='?') args = ap.parse_args() if (args.c is not None): # process c elif (args.a is not None and args.b is not None): # process a and b else: # validation errors If you were willing to make a and b a single named parameter instead of positionals, you could use mutual exclusion to do this for you. Mutually exclusive groups require all parameters in them to be optional, and named parameters can only be required. ap=argparse.ArgumentParser() g = ap.add_mutually_exclusive_group(required=True) g.add_argument('-ab', nargs=2, required=False) g.add_argument('-c', required=False) args =

Categories : Python

Python: Multi-threaded Command Line Animation
I think curses would do the job. Have a look at what is possible in this example

Categories : Python

How do I run Python script using arguments in windows command line
To execute your program from the command line, you have to call the python interpreter, like this : C:Python27>python hello.py 1 1 If you code resides in another directory, you will have to set the python binary path in your PATH environment variable, to be able to run it, too. You can find detailed instructions here.

Categories : Python

How can I use python command line arguments that change at run time?
The whole configuration is done at runtime. The examples use string constants for the names, but you are not bound to that. You first load the configuration, then when you have all the elements, simply loop over those and register them as arguments: parser = argparse.ArgumentParser(....) for element in configuration_elements: parser.add_argument('--' + element, type=float, ...) then parse your command line. Alternatively, argparse.ArgumentParser() as a partial parsing mode as well; simply call parser.parse_known_args() to parse everything that argparse does know about, it'll return a namespace object (all the options it could parse) and the remaining arguments it didn't know how to handle: >>> parser = argparse.ArgumentParser() >>> parser.add_argument('--foo')

Categories : Python

How to open a window from the command line within a Python script?
You can use subprocess module. subprocess is a newer way to spawn processes rather than using os.spawn*() or os.system(). In your case: import subprocess subprocess.Popen(["ds9"]) This should run ds9 in background. See the documentation here.

Categories : Python

Command line arguments as variable definition in Python
This is a relatively simple task with ast.literal_eval and string splitting -- But only if you have a really well defined syntax. (e.g. only 1 of --foo=bar or --foo bar is allowed). import argparse import ast parser = argparse.ArgumentParser() #allow the creation of known arguments ... namespace,unparsed = parser.parse_known_args() def parse_arg(arg): k,v = arg.split('=',1) try: v = ast.literal_eval(v) #evaluate the string as if it was a python literal except ValueError: #if we fail, then we keep it as a string pass return k.lstrip('-'),v d = dict(parse_arg(arg) for arg in unparsed) print(d) I've put the key-value pairs in a dictionary. If you really want them as global variables, you could do globals().update(d) -- But I would seriously a

Categories : Python

Infinite Amount of Command Line Arguments in Python
You don't need to, command line arguments are stored in sys.argv which will give you a list of the command line arguments. You just need to sum over them. from sys import argv print sum(map(int, argv[1:])) # We take a slice from 1: because the 0th argument is the script name. And just do python testScript.py 1 2 3 6 P.S - Command line arguments are stored as strings, so you need to map them to integers to sum over them. *args is used when you need to pass unknown number of values to a function. Consider the following - >>> def testFunc(*args): return sum(args) >>> testFunc(1, 2, 3, 4, 5, 6) 21

Categories : Python

Python arguments cuts at < when reading from command line
you need to escape the < sign. try calling: python time.py python ratatosk.py < input.txt it might be better to use a different character than < so that running this command is easier

Categories : Python

Running 7zip command line silently via Python
Pipe stdout and stderr to your system's null file: import os with open(os.devnull, 'w') as null: subprocess.Popen(['7z', 'e', input_file, '-o', output_dest, '-y'], stdout=null, stderr=null)

Categories : Python

How can I read the Command Line feedback from Python os.system()?
With your eyes. os.system only returns a number back to your process. You should use the subprocess module to read the stdout back into your process eg subprocess.check_output result = subprocess.check_output(['snmpget', '-v', '3', '-u', 'initial', '172.17.171.113', '1.3.6.1.2.1.1.5.0'])

Categories : Python

Unable to install pg gem (Rails 3 - Cygwin) - sh: : command not found
You can't mix and match native Windows code and Cygwin code. If you want to link to libpq you'll need the cygwin build libpq and you'll need to make sure the version of pg_config found on the PATH is the cygwin one. The pg_config from the native Windows build will produce output the Cygwin tools cannot understand, and even if they could they wouldn't successfully link against the native library and run with it. As I no longer use Cygwin I can't offer any advice on the current way to install libpq. Presumably there's a lib in Cygwin's package management that'll be called something like postgresql-client, libpq, etc. Cygwin is a pretty low priority platform for PostgreSQL at this point. Given that Ruby+Rails and PostgreSQL both have native Windows versions, you're setting yourself up for a

Categories : Ruby On Rails

Start Perl script via "Windows Command" through Cygwin
The parameter passed to bash will be treated as a Bash script, not a Perl script. There is no reason to use Bash in this case - just invoke Perl directly: C:cygwininperl.exe /cygdrive/c/scripts/testscript.pl If you really want to do it your way - calling a cmd script which calls a Bash script which calls a Perl script - then you would need to write a Bash script to invoke your Perl script: #!/bin/sh /cygdrive/c/scripts/testscript.pl And pass that Bash script as the parameter when you invoke bash.

Categories : Windows

Cygwin "error: command 'gcc' failed with exit status 1"
I just had this problem, The answer was here https://github.com/matplotlib/matplotlib/issues/2463 "There is a variable called "_C" defined in lib/matplotlib/tri/_tri.h on line 821 and invoked in tri.cpp on lines 2180 and 2186. For some reason gcc doesn't like this (is it a reserved word in some architecture?). I just renamed the variable to "_Co" in both tri.h and tri.cpp, and the compilation finished successfully."

Categories : Python

python script runs from command line but using subprocess gives error
When using subprocess.Popen() the first argument should be a list with a separate entry for each argument to the process you want to run: run=subprocess.Popen([sys.executable, 'maps2.py', '-i=/media/babak/LaCie/necessary/visualisation/CMIP3_Babak/Temperature/bccr_bcm2_0', '-o=temp/CMIP3', '-p=temp_001' ]) What you currently have would be the equivalent to running the following on the command line: python 'maps2.py -i=/media/babak/LaCie/necessary/visualisation/CMIP3_Babak/Temperature/bccr_bcm2_0 -o=temp/CMIP3 -p=temp_001'

Categories : Python

compare a command line argument with or statment to different strings python
How about using in? if protocol not in ("tcp", "udp"): print" error" sys.exit() FYI, instead of using sys.argv and validating script arguments manually, use argparse module from stdlib. Take a look at choices argument of add_argument method, docs: choices - A container of the allowable values for the argument.

Categories : Python

Python command line argument semicolon-loop error
If you're writing it in a script, why don't you indent it just the way you would do it in a real python program? Like this: python -mtimeit " n = 0 while n < 10: pass"

Categories : Python

How to pass dictionary as command line argument to python script?
Check this: >>> from sys import argv >>> from re import findall >>> args = ' '.join(argv[1:]) >>> pattern = r'([^=]+)s*=s*[s*([^]]+)s*]' >>> d = dict((t[0].strip(), map(lambda x: x.strip(', '),t[1].split())) for t in findall(pattern,args)) >>> for k,v in d.items(): try: d[k] = map(int,v) except: pass >>> d {'names': ['"J.J."', '"April"'], 'years': [25, 29]}

Categories : Python

Which Google authentication method i need to use for command line script in python
I would just use foauth.org which makes OAuth 2.0 much simpler. You could also use the requests-foauth library which allows to interact with foauth.org as well. Another simple (I mean clean, concise, and pythonic) library to use is python-foauth2, which comes with a full example using google APIs. Some notes: OAuth2 Service account are meant for server to server applications, meaning it should not be tied to your account (or your calendar). For scripts, it's much better to follow the instructions for OAuth2 for installed apps; open up a browser to authorize the app / script and get a code that you can redeem for a token. The instructions for OAuth2 for devices is almost the same but provides 2 codes, one to enter in a browser and one to store on the device (or both from a computer...).

Categories : Python

How to Run a Command Line python script in IDLE in windows Environment
It doesn't seem like IDLE provides a way to do this through the GUI, but you could do something like: mocking them in your if __name__ == '__main__': where you intercept the command line arguments. try: __file__ except: sys.argv = [sys.argv[0], 'argument1', 'argument2', 'argument2'] You can also try, idle.py -r scriptname.py arg1 arg2 arg3

Categories : Python

python read in multiple key value (dict) from command line into a variable
Use argparse with a custom action: import argparse import copy class DictAction(argparse.Action): def __call__(self, parser, namespace, values, option_string=None): try: k, v = values.split("=", 1) except ValueError: raise argparse.ArgumentError(self, "Format must be key=value") # Implementation is from argparse._AppendAction items = copy.copy(argparse._ensure_value(namespace, self.dest, {})) # Default mutables, use copy! items[k] = v setattr(namespace, self.dest, items) # Usage: parser = argparse.ArgumentParser() parser.add_argument("--define", action=DictAction) print parser.parse_args("--define k=v --define x=y".split()) # Gives # Namespace(d={'x': 'y', 'k': 'v'}) print parser.parse_args("--define k=v --

Categories : Python

OpenCV using command line argument for input image (Python)
In python and most other languages argv[0] contains the program name. Try using argv[1] to get the correct result. Here is some Python Documentation to help you. Python has an amazing library of documentation I highly recommend using it.

Categories : Python

Using windows command line to run python script with passing of url argument
I think the problem is the way you specify your url, it needs to have the http:// part at the start. It works for me when I type python sys.py http://www.google.com/ but fails with python sys.py www.google.com (Note that I am using linux with python 2.7 but I think it may be the same problem for you)

Categories : Windows



© Copyright 2017 w3hello.com Publishing Limited. All rights reserved.