Search Results

Search found 19863 results on 795 pages for 'python subprocess module'.

Page 4/795 | < Previous Page | 1 2 3 4 5 6 7 8 9 10 11 12  | Next Page >

  • sudo apt-get install python.pip python-dev Gives Error

    - by user2539745
    I am learning Django from http://gettingstartedwithdjango.com/ and I have windows 7 32-bit. The tutorial asked to install virtualbox and vagrant(tutorial had precise64 and it had issues in my pc so I installed precise32) so I did it. Now the tutorial asked to do sudo apt-get install python-dev python.pip so I did it but it gave me this error > vagrant@precise32:~$ sudo apt-get install python.pip python-dev Reading package lists... Done Building dependency tree Reading state information... Done Note, selecting 'python-pip' for regex 'python.pip' Note, selecting 'python-pipeline' for regex 'python.pip' The following extra packages will be installed: libexpat1 libexpat1-dev libpython2.7 python-pkg-resources python-setuptools python-support python2.7 python2.7-dev python2.7-minimal Suggested packages: python-distribute python-distribute-doc python2.7-doc binfmt-support The following NEW packages will be installed: libexpat1-dev libpython2.7 python-dev python-pip python-pipeline python-pkg-resources python-setuptools python-support python2.7-dev The following packages will be upgraded: libexpat1 python2.7 python2.7-minimal 3 upgraded, 9 newly installed, 0 to remove and 63 not upgraded. Need to get 34.7 MB/35.7 MB of archives. After this operation, 42.0 MB of additional disk space will be used. Do you want to continue [Y/n]? y Err (http removed)us.archive.ubuntu.com/ubuntu/ precise-updates/main python2.7 i386 2.7 .3-0ubuntu3.1 404 Not Found [IP: 91.189.91.15 80] Err (http removed)us.archive.ubuntu.com/ubuntu/ precise-updates/main python2.7-minimal i386 2.7.3-0ubuntu3.1 404 Not Found [IP: 91.189.91.15 80] Err (http removed)us.archive.ubuntu.com/ubuntu/ precise-updates/main libpython2.7 i386 2.7.3-0ubuntu3.1 404 Not Found [IP: 91.189.91.15 80] Err (http removed)us.archive.ubuntu.com/ubuntu/ precise-updates/main python2.7-dev i386 2.7.3-0ubuntu3.1 404 Not Found [IP: 91.189.91.15 80] Failed to fetch (http removed)us.archive.ubuntu.com/ubuntu/pool/main/p/python2.7/python 2.7_2.7.3-0ubuntu3.1_i386.deb 404 Not Found [IP: 91.189.91.15 80] Failed to fetch (http removed)us.archive.ubuntu.com/ubuntu/pool/main/p/python2.7/python 2.7-minimal_2.7.3-0ubuntu3.1_i386.deb 404 Not Found [IP: 91.189.91.15 80] Failed to fetch (http removed)us.archive.ubuntu.com/ubuntu/pool/main/p/python2.7/libpyt hon2.7_2.7.3-0ubuntu3.1_i386.deb 404 Not Found [IP: 91.189.91.15 80] Failed to fetch (http removed)us.archive.ubuntu.com/ubuntu/pool/main/p/python2.7/python 2.7-dev_2.7.3-0ubuntu3.1_i386.deb 404 Not Found [IP: 91.189.91.15 80] E: Unable to fetch some archives, maybe run apt-get update or try with --fix-mis sing? Please help what should I do ??

    Read the article

  • Python IDLE: How to type correct indentation?

    - by user2988464
    Mac: Maverick Python: 3.4 I tried to testtimeit module in Python's IDLE import timeit >>> timeit.timeit( "obj.method", """ class SomeClass: def method(self): pass obj = SomeClass() """) When I tried to type def method(self): on the next line of class SomeClass, I hit Tab, it prompted a window showing the files inside my Document directory. So I hit Ctrl+Tab instead. But I still got the error: Traceback (most recent call last): File "<pyshell#26>", line 6, in <module> """) File "/Library/Frameworks/Python.framework/Versions/3.4/lib/python3.4/timeit.py", line 213, in timeit return Timer(stmt, setup, timer).timeit(number) File "/Library/Frameworks/Python.framework/Versions/3.4/lib/python3.4/timeit.py", line 122, in __init__ code = compile(src, dummy_src_name, "exec") File "<timeit-src>", line 9 _t0 = _timer() ^ IndentationError: unindent does not match any outer indentation level Can someone explain: how to fix it, and how to avoid the prompt of My Document appear? Thx!!!

    Read the article

  • How to install python modules for specific python version

    - by Zayatzz
    I needed to install UCS2 python next to UCS4 python. So I went to comp.lang.python and asked them about it. Probably not the best place to ask it, but they answered https://groups.google.com/forum/?fromgroups#!topic/comp.lang.python/bGuAfqa76W8 and now i have brand new python 2.7.3 ucs2 installed in /opt/bin/python What I need now is - how can I install all other python modules that I have installed for that python version also. Basically stuff like PIL and postgresql and mod_wsgi - basically everything needed to run Django for that python version. Is this the right the place to ask for it?

    Read the article

  • call python with system() in R to run a python script emulating the python console

    - by Yihui
    I want to pass a chunk of Python code to Python in R with something like system('python ...'), and I'm wondering if there is an easy way to emulate the python console in this case. For example, suppose the code is "print 'hello world'", how can I get the output like this in R? >>> print 'hello world' hello world This only shows the output: > system("python -c 'print \"hello world\"'") hello world Thanks! BTW, I asked in r-help but have not got a response yet (if I do, I'll post the answer here).

    Read the article

  • Python-How to call up a function from another module?

    - by user2691540
    I am making a project where I need several modules which are imported into one main module to make a pizza ordering service. Upon finishing this (to a working standard) I decided to re-code it so that the whole order is completed with one tkinter window, now instead of using input(), I use tkinter.Entry() etc. etc. To do this I had to use functions for each step so it is broken up nicely, e.g. the code asks if the user wants pickup or delivery, the user clicks a button which sets some variables and one of the buttons is then configured to say "continue" and the command leads to the next step of the pizza ordering process e.g. getting the name. The problem I have is that when I get past the last function of the first module the configured button has a command to go to a function in the second module, but it says that the command is not defined??? I have tried my way around this but cannot import the configured button variable into the next module, and anything else I tried gave no result, it simply doesn't go to the next module after the first module is done. I have made the main tkinter window in the main module and have it that it will mainloop after importing the other modules so shouldn't the function I want to call upon be defined? How can I get from one function to the next if the latter is in a seperate module? Is this possible or do I have to rethink my approach and if so how? Ok then, have made some more code to show what my problem is, this isn't what I am actually using but it's a lot shorter and has the same issue: this is the main module: import tkinter mainwindow = tkinter.Tk() # here i set the window to a certain size etc. import mod1 import mod2 mainwindow.mainloop() this is mod1: import tkinter def button1(): label.destroy() button1.destroy() button2.config(text = "continue", command = func2) def button2(): label.destroy() button1.destroy() button2.config(text = "continue", command = func2) label = tkinter.Label(text = "example label") button1 = tkinter.Button(text = "button1", command = button1) button2 = tkinter.Button(text = "button2", command = button2) label.pack() button1.pack() button2.pack() this is mod2: def func2(): button2.destroy() print ("haha it works...") I still get the problem that func2 is not defined? Thanks in advance

    Read the article

  • New at Python: GLPK not building properly / Python ImportError

    - by Merjit
    This is a beginner question, and a follow-up to this one, where I was pointed to GLPK. I'm trying to get PyGLPK, a Python binding for the GNU Linear Programming Kit up and running, but no matter what I do, I can't seem to build and install GLPK so that Python finds it correctly. This comes after running ./configure, make, and sudo make install on the GLPK libraries, and following the instructions for PyGLPK. Specifically, here is the error I get: >>> import glpk Traceback (most recent call last): File "<stdin>", line 1, in <module> ImportError: dlopen(/Library/Frameworks/Python.framework/Versions/2.6/lib/python2.6/site- packages/glpk.so, 2): Symbol not found: __glp_lpx_print_ips Referenced from: /Library/Frameworks/Python.framework/Versions/2.6/lib/python2.6/site-packages/glpk.so Expected in: dynamic lookup I assume that something isn't linking to somewhere else, and that it probably has something to do with paths and environment variables. However, here's where my abilities in the shell fail, and I'm at a loss over what to do next. Again, there is probably a simple answer to this, but I haven't had any luck with Google using the terminology I know.

    Read the article

  • Installing PIL (Python Imaging Library) in Win7 64 bits, Python 2.6.4

    - by Rafael Almeida
    I'm trying to install said library for use with Python. I tried downloading the executable installer for Windows, which runs, but says it doesn't find a Python installation. Then tried registering (http://effbot.org/zone/python-register.htm) Python, but the script says it can't register (although the keys appear in my register). Then I tried downloading the source package: I run the setup.py build and it works, but when I run setup.py install it says the following: running install running build running build_py running build_ext building '_imaging' extension error: Unable to find vcvarsall.bat What can I do?

    Read the article

  • Python subprocess Popen.communicate() equivalent to Popen.stdout.read()?

    - by Christophe
    Very specific question (I hope): What are the differences between the following three codes? (I expect it to be only that the first does not wait for the child process to be finished, while the second and third ones do. But I need to be sure this is the only difference...) I also welcome other remarks/suggestions (though I'm already well aware of the shell=True dangers and cross-platform limitations) Note that I already read Python subprocess interaction, why does my process work with Popen.communicate, but not Popen.stdout.read()? and that I do not want/need to interact with the program after. Also note that I already read Alternatives to Python Popen.communicate() memory limitations? but that I didn't really get it... First code: from subprocess import Popen, PIPE def exe_f(command='ls -l', shell=True): "Function to execute a command and return stuff" process = Popen(command, shell=shell, stdout=PIPE, stderr=PIPE) stdout = process.stdout.read() stderr = process.stderr.read() return process, stderr, stdout Second code: from subprocess import Popen, PIPE from subprocess import communicate def exe_f(command='ls -l', shell=True): "Function to execute a command and return stuff" process = Popen(command, shell=shell, stdout=PIPE, stderr=PIPE) (stdout, stderr) = process.communicate() return process, stderr, stdout Third code: from subprocess import Popen, PIPE from subprocess import wait def exe_f(command='ls -l', shell=True): "Function to execute a command and return stuff" process = Popen(command, shell=shell, stdout=PIPE, stderr=PIPE) code = process.wait() stdout = process.stdout.read() stderr = process.stderr.read() return process, stderr, stdout Thanks.

    Read the article

  • How to become a solid python web developer [closed]

    - by Estarius
    Possible Duplicate: How do I learn Python from zero to web development? I have started Python recently with the goal to become a solid developer to make a web application eventually. However, as time goes by I am wondering if I am being optimal about how I will achieve my goal. I would compare it to a game for example, to be better you must spend time playing and trying new things... However, if you just log in and sit in the lobby chatting you are most likely not progressing. So far, this is my plan (feel free to comment or judge it): Review basic programmation concepts Start coding slowly in Python Once comfortable in Python, learn about web development in Python Learn about those things we heard about: SQLAlchemy, MVC, TDD, Git, Agile (Group project) To achieve these things, I started the Learn python the hard way exercises, which I am doing at the rate of 5 per days. I also started to read Think Python at the same time and planning to move on with Dive into python. As far as my research goes, these documentations along with Python documentation is usually what is the most recommended to learn Python. I consider this to get my point 1 and 2 done. While learning Python is really great, my goal remains to do quality web development. I know there are books about Django etc. however I would like to become comfortable with any Python web development. This means without Framework and with Framework... Any framework, then be able to choose the one which best fits our needs. For this I would like to know if some people have suggestions. Should I just get a book on Django and it should apply to everything ? What would be the best method to go from Python to Web Python and not end up creating crappy code which would turn into nightmares for other programmers ? Then finally, those "things we hear about". While I understand what they all do basically, I am fairly sure that like everything, there are good and wrong ways of making use of them. Should I go through at least a whole book on each before starting to use them or keep it at their respective online documentation ? Are there some kind of documentation which links their use to Python ? Also, from looking at Django and Pyramid they seems to use something else than MVC, while the Django model looks similar, the Pyramid one seems to cut a whole part of it... Is learning MVC still worth it ? Sorry for the wall of text, Thanks in advance !

    Read the article

  • Why do people hesitate using Python 3?

    - by Ham
    Python 3 has been released in December 2008. A lot of time has passed since then but still today many developers hesitate using Python 3. Even popular frameworks like Django are not compatible with Python 3 yet but still rely on Python 2. Sure, Python 3 has some incompatibilities to Python 2 and some people need to rely on backwards-compatibility. But hasn't Python 3 been around long enough now for most projects to switch or start with Python 3? Having two competiting versions has so many drawbacks; two branches need to be maintained, confusion for learners and so on, so why is there such a big hesitation throughout the Python community in switching to Python 3?

    Read the article

  • Python - Code snippet not working on Python 2.5.6, using IDLE

    - by Francisco P.
    Hello, everyone I am using a piece of self-modifying code for a college project. Here it is: import datetime import inspect import re import sys def main(): # print the time it is last run lastrun = 'Mon Jun 8 16:31:27 2009' print "This program was last run at ", print lastrun # read in the source code of itself srcfile = inspect.getsourcefile(sys.modules[__name__]) f = open(srcfile, 'r') src = f.read() f.close() # modify the embedded timestamp timestamp = datetime.datetime.ctime(datetime.datetime.now()) match = re.search("lastrun = '(.*)'", src) if match: src = src[:match.start(1)] + timestamp + src[match.end(1):] # write the source code back f = open(srcfile, 'w') f.write(src) f.close() if __name__=='__main__': main() Unfortunately, it doesn't work. Error returned: # This is the script's output This program is last run at Mon Jun 8 16:31:27 2009 # This is the error message Traceback (most recent call last): File "C:\Users\Rui Gomes\Desktop\teste.py", line 30, in <module> main() File "C:\Users\Rui Gomes\Desktop\teste.py", line 13, in main srcfile = inspect.getsourcefile(sys.modules[__name__]) File "C:\Python31\lib\inspect.py", line 439, in getsourcefile filename = getfile(object) File "C:\Python31\lib\inspect.py", line 401, in getfile raise TypeError('{!r} is a built-in module'.format(object)) TypeError: <module '__main__' (built-in)> is a built-in module I'd be thankful for any solutions.

    Read the article

  • Non-blocking read on a stream in python.

    - by Mathieu Pagé
    Hi, I'm using the subprocess module to start a subprocess and connect to it's output stream (stdout). I want to be able to execute non-blocking reads on its stdout. Is there a way to make .readline non-bloking or to check if there is data on the stream before I invoke .readline? I'd like this to be portable or at least work under Windows and Linux. here is how I do it for now (It's blocking on the .readline if no data is avaible): p = subprocess.Popen('myprogram.exe', stdout = subprocess.PIPE) str = p.stdout.readline() Thanks for your help.

    Read the article

  • Python encoding for pipe.communicate

    - by Brian M. Hunt
    I'm calling pipe.communicate from Python's subprocess module from Python 2.6. I get the following error from this code: from subprocess import Popen pipe = Popen(cwd) pipe.communicate( data ) For an arbitrary cwd, and where data that contains unicode (specifically 0xE9): Exec. exception: 'ascii' codec can't encode character u'\xe9' in position 507: ordinal not in range(128) Traceback (most recent call last): ... stdout, stderr = pipe.communicate( data ) File "/System/Library/Frameworks/Python.framework/Versions/2.6/lib/python2.6/subprocess.py", line 671, in communicate return self._communicate(input) File "/System/Library/Frameworks/Python.framework/Versions/2.6/lib/python2.6/subprocess.py", line 1177, in _communicate bytes_written = os.write(self.stdin.fileno(), chunk) This is happening, I presume, because pipe.communicate() is expecting ASCII encoded string, but data is unicode. Is this the problem I'm encountering, and i sthere a way to pass unicode to pipe.communicate()? Thank you for reading! Brian

    Read the article

  • dynamic module creation

    - by intuited
    I'd like to dynamically create a module from a dictionary, and I'm wondering if adding an element to sys.modules is really the best way to do this. EG context = { a: 1, b: 2 } import types test_context_module = types.ModuleType('TestContext', 'Module created to provide a context for tests') test_context_module.__dict__.update(context) import sys sys.modules['TestContext'] = test_context_module My immediate goal in this regard is to be able to provide a context for timing test execution: import timeit timeit.Timer('a + b', 'from TestContext import *') It seems that there are other ways to do this, since the Timer constructor takes objects as well as strings. I'm still interested in learning how to do this though, since a) it has other potential applications; and b) I'm not sure exactly how to use objects with the Timer constructor; doing so may prove to be less appropriate than this approach in some circumstances. EDITS/REVELATIONS/PHOOEYS/EUREKAE: I've realized that the example code relating to running timing tests won't actually work, because import * only works at the module level, and the context in which that statement is executed is that of a function in the testit module. In other words, the globals dictionary used when executing that code is that of main, since that's where I was when I wrote the code in the interactive shell. So that rationale for figuring this out is a bit botched, but it's still a valid question. I've discovered that the code run in the first set of examples has the undesirable effect that the namespace in which the newly created module's code executes is that of the module in which it was declared, not its own module. This is like way weird, and could lead to all sorts of unexpected rattlesnakeic sketchiness. So I'm pretty sure that this is not how this sort of thing is meant to be done, if it is in fact something that the Guido doth shine upon. The similar-but-subtly-different case of dynamically loading a module from a file that is not in python's include path is quite easily accomplished using imp.load_source('NewModuleName', 'path/to/module/module_to_load.py'). This does load the module into sys.modules. However this doesn't really answer my question, because really, what if you're running python on an embedded platform with no filesystem? I'm battling a considerable case of information overload at the moment, so I could be mistaken, but there doesn't seem to be anything in the imp module that's capable of this. But the question, essentially, at this point is how to set the global (ie module) context for an object. Maybe I should ask that more specifically? And at a larger scope, how to get Python to do this while shoehorning objects into a given module?

    Read the article

  • Python IPC, popen too slow

    - by UnableToLoad
    i need to run a subprocess (./myProgram) form python script and get output, actually i do this: import subprocess proc = subprocess.Popen('./generate_out', shell=False, stdout=subprocess.PIPE, ) while proc.poll() is None: out = proc.stdout.readline() data = doStuff(out) print(data) but is slow, sometimes pass a lot of time between the output produced by ./generate_out and the print(data), knowing that my doStuff() function is very fast, i think there is some buffer slowing down my pipe... Notes: ./generate_out, generates potentially an unlimited number of lines of finite length each. It seems that when too few chars are put in the pipe between the two processes nothing happens, then when enough is produced i get a huge print (non the expected behaviour!) sometimes i wait many seconds (10-20 and more) between generate_out print and python print) what can i do? maybe communicate() is faster? anithing else? Thank you a lot!

    Read the article

  • Cannot compile GDB7.8 with Python support

    - by j0h
    I am trying to install GDB7.8 with Python support. From the source folder, I am running ./configure --with-python When I did tab-complete from --with- I did not see Python in the list. But when I ran configure with that flag, it did not baulk. When I run make, it complains that Python is not found. checking for python2.7... no but Python is installed: $ which python python python2.7 python2.7-dbg-config python2 python2.7-dbg $ which python2.7 /usr/bin/python2.7 I compiled GDB without --with-python and things installed without error. I was under the impression that GDB7.8 had Python support without the need for special flags. But when I run: $gdb python (gdb) run test.py I get some sort of cannot import gdb Import error So then I tried calling "pi": (gdb) pi printf.py Python scripting is not supported in this copy of GDB. So... how do I get Python support in GDB7.8? is it actually not supported? Or should I not call "pi"?

    Read the article

  • What causes subprocess.call to output blank file when attempting db export with mysqldump?

    - by caldazar
    I am having some problems using subprocess.call to export a database using mysqldump. I'm using Python 3.1 installed on Windows 7. from time import gmtime, strftime import subprocess DumpDir = "c:/apps/sqlbackup/"; DumpFile = "mysqldump-" + strftime("%Y-%m-%d-%H-%M-%S", gmtime()) + ".sql"; params = [r"mysqldump --user root --password=mypassword --force --flush-privileges --compress --comments mydatabase --result-file=" + DumpDir + DumpFile]; subprocess.call(params, shell=True); The above code causes a blank file to be created in the DumpDir. I've tried getting python to print the command so I can test it via the CMD prompt using: print(subprocess.list2cmdline(params)); If I paste the output to the CMD prompt and execute it, everything works fine. Any ideas? I'm new to Python, so I am sure the answer is simple but I've tried so many variations to get this working that I just can't figure this out.

    Read the article

  • Fastest image iteration in Python

    - by Greg
    I am creating a simple green screen app with Python 2.7.4 but am getting quite slow results. I am currently using PIL 1.1.7 to load and iterate the images and saw huge speed-ups changing from the old getpixel() to the newer load() and pixel access object indexing. However the following loop still takes around 2.5 seconds to run for an image of around 720p resolution: def colorclose(Cb_p, Cr_p, Cb_key, Cr_key, tola, tolb): temp = math.sqrt((Cb_key-Cb_p)**2+(Cr_key-Cr_p)**2) if temp < tola: return 0.0 else: if temp < tolb: return (temp-tola)/(tolb-tola) else: return 1.0 .... for x in range(width): for y in range(height): Y, cb, cr = fg_cbcr_list[x, y] mask = colorclose(cb, cr, cb_key, cr_key, tola, tolb) mask = 1 - mask bgr, bgg, bgb = bg_list[x,y] fgr, fgg, fgb = fg_list[x,y] pixels[x,y] = ( (int)(fgr - mask*key_color[0] + mask*bgr), (int)(fgg - mask*key_color[1] + mask*bgg), (int)(fgb - mask*key_color[2] + mask*bgb)) Am I doing anything hugely inefficient here which makes it run so slow? I have seen similar, simpler examples where the loop is replaced by a boolean matrix for instance, but for this case I can't see a way to replace the loop. The pixels[x,y] assignment seems to take the most amount of time but not knowing Python very well I am unsure of a more efficient way to do this. Any help would be appreciated.

    Read the article

  • Python requests - saving cookie for later url usage

    - by PythonRocks
    I been trying to get a cookie and post it to a url in later use in the program, but I cant seem to get the cookie parameters to work. Right now I have response = requests.get("url") But how exactly do I retrive cookies from this url and post them to a new url (the same cookies). The tutorial in requests is somewhat vague on the topic and gives examples I cannot test. Hope someone can help with further examples. This is python 2.7 btw.

    Read the article

  • Python Parse regex

    - by Nemo
    Let's say I have string in the form given below: myString={"name", "age", "address", "contacts", "Email"} I need to get all the items of myString into a List using python. Here's what I did r= re.search("myString=\{\"(.+)\", $\}", line) if r: items.append(r.group(1)) print(items) Here line is the variable that holds the content of my text file. What change do I have to make to my regex to get all the items in myString? Please kindly help me out. Thanks.

    Read the article

  • python metaprogramming

    - by valya
    I'm trying to archive a task which turns out to be a bit complicated since I'm not very good at Python metaprogramming. I want to have a module locations with function get_location(name), which returns a class defined in a folder locations/ in the file with the name passed to function. Name of a class is something like NameLocation. So, my folder structure: program.py locations/ __init__.py first.py second.py program.py will be smth with with: from locations import get_location location = get_location('first') and the location is a class defined in first.py smth like this: from locations import Location # base class for all locations, defined in __init__ (?) class FirstLocation(Location): pass etc. Okay, I've tried a lot of import and getattribute statements but now I'm bored and surrender. How to archive such behaviour?

    Read the article

  • bad request error 400 while using python requests.post function

    - by Toussah
    I'm trying to make a simple post request via the requests library of Python and I get a bad request error (400) while my url is supposedly correct since I can use it to perform a get. I'm very new in REST requests, I read many tutorials and documentation but I guess there are still things I don't get so my error could be basic. Maybe a lack of understanding on the type of url I'm supposed to send via POST. Here my code : import requests v_username = "username" v_password = "password" v_headers = {'content-type':'application/rdf+xml'} url = 'https://my.url' params = {'param': 'val_param'} payload = {'data': 'my_data'} r = requests.post(url, params = params, auth=(v_username, v_password), data=payload, headers=v_headers, verify=False) print r I used the example of the requests documentation.

    Read the article

< Previous Page | 1 2 3 4 5 6 7 8 9 10 11 12  | Next Page >