Search Results

Search found 97 results on 4 pages for 'python3'.

Page 3/4 | < Previous Page | 1 2 3 4  | Next Page >

  • Python 3.3 Webserver restarting problems

    - by IPDGino
    I have made a simple webserver in python, and had some problems with it before as described here: Python (3.3) Webserver script with an interesting error In that question, the answer was to use a While True: loop so that any crashes or errors would be resolved instantly, because it would just start itself again. I've used this for a while, and still want to make the server restart itself every few minutes, but on Linux for some reason it won't work for me. On windows the code below works fine, but on linux it keeps saying Handler class up here ... ... class Server: def __init__(self): self.server_class = HTTPServer self.server_adress = ('MY IP GOES HERE, or localhost', 8080) global httpd httpd = self.server_class(self.server_adress, Handler) self.main() def main(self): if count > 1: global SERVER_UP_SINCE HOUR_CHECK = int(((count - 1) * RESTART_INTERVAL) / 60) SERVER_UPTIME = str(HOUR_CHECK) + " MINUTES" if HOUR_CHECK > 60: minutes = int(HOUR_CHECK % 60) hours = int(HOUR_CHECK // 60) SERVER_UPTIME = ("%s HOURS, %s MINUTES" % (str(hours), str(minutes))) SERVING_ON_ADDR = self.server_adress SERVER_UP_SINCE = str(SERVER_UP_SINCE) SERVER_RESTART_NUMBER = count - 1 print(""" SERVER INFO ------------------------------------- SERVER_UPTIME: %s SERVER_UP_SINCE: %s TOTAL_FILES_SERVED: %d SERVING_ON_ADDR: %s SERVER_RESTART_NUMBER: %s \n\nSERVER HAS RESTARTED """ % (SERVER_UPTIME, SERVER_UP_SINCE, TOTAL_FILES, SERVING_ON_ADDR, SERVER_RESTART_NUMBER)) else: print("SERVER_BOOT=1\nSERVER_ONLINE=TRUE\nRESTART_LOOP=TRUE\nSERVING_ON_ADDR:%s" % str(self.server_adress)) while True: try: httpd.serve_forever() except KeyboardInterrupt: print("Shutting down...") break httpd.shutdown() httpd.socket.close() raise(SystemExit) return def server_restart(): """If you want the restart timer to be longer, replace the number after the RESTART_INTERVAL variable""" global RESTART_INTERVAL RESTART_INTERVAL = 10 threading.Timer(RESTART_INTERVAL, server_restart).start() global count count = count + 1 instance = Server() if __name__ == "__main__": global SERVER_UP_SINCE SERVER_UP_SINCE = strftime("%d-%m-%Y %H:%M:%S", gmtime()) server_restart() Basically, I make a thread to restart it every 10 seconds (For testing purposes) and start the server. After ten seconds it will say File "/home/username/Desktop/Webserver/server.py", line 199, in __init__ httpd = self.server_class(self.server_adress, Handler) File "/usr/lib/python3.3/socketserver.py", line 430, in __init__ self.server_bind() File "/usr/lib/python3.3/http/server.py", line 135, in server_bind socketserver.TCPServer.server_bind(self) File "/usr/lib/python3.3/socketserver.py", line 441, in server_bind self.socket.bind(self.server_address) OSError: [Errno 98] Address already in use As you can see in the except KeyboardInterruption line, I tried everything to make the server stop, and the program stop, but it will NOT stop. But the thing I really want to know is how to make this server able to restart, without giving some wonky errors.

    Read the article

  • Building Python 3.2.3 on redhat 5: missing _posixsubprocess

    - by Oz123
    I am trying to build Python3 on a RHEL 5.7 machine, I successful managed to build Python 3.2.2, with : # Install required build dependencies yum install openssl-devel bzip2-devel expat-devel gdbm-devel readline-devel sqlite-devel # Fetch and extract source. Please refer to http://www.python.org/download/releases # to ensure the latest source is used. wget http://www.python.org/ftp/python/3.2/Python-3.2.tar.bz2 tar -xjf Python-3.2.tar.bz2 cd Python-3.2 # Configure the build with a prefix (install dir) of /opt/python3, compile, and install. ./configure --prefix=/opt/python3 make But I am failing (?) with Python 3.2.3: Failed to build these modules: _posixsubprocess Is this a problem that should bother me ? How do I build it? I found this patch, but it's not included in sources Python 3.2.3 I obtained from the website ... Applying this patch on my sources, didn't solve the problem ... Here is the output from stderr: ~/tmp/Python-3.2.3 $ make > build.log ldd: warning: you do not have execution permission for `/usr/local/lib/libreadline.so' /usr/bin/ld: skipping incompatible /usr/local/lib/libreadline.so when searching for -lreadline /usr/bin/ld: skipping incompatible /usr/local/lib/libreadline.a when searching for -lreadline /home/oznahum/tmp/Python-3.2.3/Modules/_posixsubprocess.c: In function '_close_open_fd_range_safe': /home/oznahum/tmp/Python-3.2.3/Modules/_posixsubprocess.c:205: error: 'O_CLOEXEC' undeclared (first use in this function) /home/oznahum/tmp/Python-3.2.3/Modules/_posixsubprocess.c:205: error: (Each undeclared identifier is reported only once /home/oznahum/tmp/Python-3.2.3/Modules/_posixsubprocess.c:205: error: for each function it appears in.) /usr/bin/ld: skipping incompatible /usr/local/lib/libz.so when searching for -lz /usr/bin/ld: skipping incompatible /usr/local/lib/libz.so when searching for -lz ~/tmp/Python-3.2.3 $ grep posix build.log gcc -pthread -fno-strict-aliasing -DNDEBUG -g -fwrapv -O3 -Wall -Wstrict-prototypes -I. -IInclude -I./Include -DPy_BUILD_CORE -c ./Modules/posixmodule.c -o Modules/posixmodule.o ar rc libpython3.2m.a Modules/_threadmodule.o Modules/signalmodule.o Modules/posixmodule.o Modules/errnomodule.o Modules/pwdmodule.o Modules/_sre.o Modules/_codecsmodule.o Modules/_weakref.o Modules/_functoolsmodule.o Modules/operator.o Modules/_collectionsmodule.o Modules/itertoolsmodule.o Modules/_localemodule.o Modules/_iomodule.o Modules/iobase.o Modules/fileio.o Modules/bytesio.o Modules/bufferedio.o Modules/textio.o Modules/stringio.o Modules/zipimport.o Modules/symtablemodule.o Modules/xxsubtype.o building '_posixsubprocess' extension gcc -pthread -fPIC -fno-strict-aliasing -DNDEBUG -g -fwrapv -O3 -Wall -Wstrict-prototypes -IInclude -I/home/oznahum/localroot/include -I. -I./Include -I/usr/local/include -I/home/oznahum/tmp/Python-3.2.3 -c /home/oznahum/tmp/Python-3.2.3/Modules/_posixsubprocess.c -o build/temp.linux-x86_64-3.2/home/oznahum/tmp/Python-3.2.3/Modules/_posixsubprocess.o _posixsubprocess

    Read the article

  • CentOS (rel6) with default python 2.6, but seperate 3.3.5 installation

    - by Silvertiger
    I have a CentOS server (rel6) that had python installed (2.6), but I needed a few features in 3.3+. I installed 3.3 into a seperate folder and made a symbolic link to execute it: I installed setup tools: yum install python-setuptools I installed a needed module"pandas" easy_install pandas I executed my pyton script, which encountered an error that required i use a newer version I downloaded and installed Python 3.3.5 to it's own folder so as to not override my default python wget http://www.python.org/ftp/python/3.3.5/Python-3.3.5.tar.xz tar xJf ./Python-3.3.5.tar.xz cd ./Python-3.3.5 ./configure --prefix=/opt/python make make install Made s symbolic link to allow me to execute this new python: ln -s /opt/python3.3/bin/python3.3 ~/bin/py The problem is that when I execute the python script with my new py alias, it does not have all the addons needed (explicitly MySQLdb) which the default install does. How do i go about installing the MySQLdb module, or any for that matter, to be reachable or useable for the new Python 3.3.5 installation? Or is there a way to make the current modules in 2.6 available to 3.3.5 as well?

    Read the article

  • Installing Lubuntu 14.04.1 fails, upowerd appears to hang

    - by Rantanplan
    On the live-CD session, I tried installing Lubuntu double clicking on the install button on the desktop. Here, the CD starts running but then stops running and nothing happens. Next, I rebooted and tried installing Lubuntu directly from the boot menu screen using forcepae again. After a while, I receive the following error message: The installer encountered an unrecoverable error. A desktop session will now be run so that you may investigate the problem or try installing again. Hitting Enter brings me to the desktop. For what errors should I search? And how? Thanks for some hints! On Lubuntu 12.04: uname -a Linux humboldt 3.2.0-67-generic #101-Ubuntu SMP Tue Jul 15 17:45:51 UTC 2014 i686 i686 i386 GNU/Linux lsb_release -a No LSB modules are available. Distributor ID: Ubuntu Description: Ubuntu 12.04.5 LTS Release: 12.04 Codename: precise upowerd appears to hang: Aug 25 10:53:28 lubuntu kernel: [ 367.920272] INFO: task upowerd:3002 blocked for more than 120 seconds. Aug 25 10:53:28 lubuntu kernel: [ 367.920288] Tainted: G S C 3.13.0-32-generic #57-Ubuntu Aug 25 10:53:28 lubuntu kernel: [ 367.920294] "echo 0 > /proc/sys/kernel/hung_task_timeout_secs" disables this message. Aug 25 10:53:28 lubuntu kernel: [ 367.920300] upowerd D e21f9da0 0 3002 1 0x00000000 Aug 25 10:53:28 lubuntu kernel: [ 367.920314] e21f9dfc 00000086 f5ef7094 e21f9da0 c1050272 c1a8d540 c1920a00 00000000 Aug 25 10:53:28 lubuntu kernel: [ 367.920333] c1a8d540 c1920a00 d9e44da0 f5ef6540 c1129061 00000002 000001c1 0001c37b Aug 25 10:53:28 lubuntu kernel: [ 367.920351] 00000000 00000002 00000000 e2276240 00000000 00000040 c12b0ec5 c19975a8 Aug 25 10:53:28 lubuntu kernel: [ 367.920368] Call Trace: Aug 25 10:53:28 lubuntu kernel: [ 367.920389] [<c1050272>] ? kmap_atomic_prot+0x42/0x100 Aug 25 10:53:28 lubuntu kernel: [ 367.920404] [<c1129061>] ? get_page_from_freelist+0x2a1/0x600 Aug 25 10:53:28 lubuntu kernel: [ 367.920417] [<c12b0ec5>] ? process_measurement+0x65/0x240 Aug 25 10:53:28 lubuntu kernel: [ 367.920432] [<c1654c73>] schedule_preempt_disabled+0x23/0x60 Aug 25 10:53:28 lubuntu kernel: [ 367.920443] [<c16565bd>] __mutex_lock_slowpath+0x10d/0x171 Aug 25 10:53:28 lubuntu kernel: [ 367.920454] [<c1655aec>] mutex_lock+0x1c/0x28 Aug 25 10:53:28 lubuntu kernel: [ 367.920478] [<f857223a>] acpi_smbus_transaction+0x48/0x210 [sbshc] Aug 25 10:53:28 lubuntu kernel: [ 367.920489] [<c11858e1>] ? do_last+0x1b1/0xf60 Aug 25 10:53:28 lubuntu kernel: [ 367.920504] [<f857242f>] acpi_smbus_read+0x2d/0x33 [sbshc] Aug 25 10:53:28 lubuntu kernel: [ 367.920520] [<f881e0f1>] acpi_battery_get_state+0x74/0x8b [sbs] Aug 25 10:53:28 lubuntu kernel: [ 367.920535] [<f881e8a9>] acpi_sbs_battery_get_property+0x2a/0x233 [sbs] Aug 25 10:53:28 lubuntu kernel: [ 367.920549] [<c14fa61f>] power_supply_show_property+0x3f/0x240 Aug 25 10:53:28 lubuntu kernel: [ 367.920561] [<c114664f>] ? handle_mm_fault+0x64f/0x8d0 Aug 25 10:53:28 lubuntu kernel: [ 367.920573] [<c14fa5e0>] ? power_supply_store_property+0x60/0x60 Aug 25 10:53:28 lubuntu kernel: [ 367.920586] [<c1407d20>] ? dev_uevent_name+0x30/0x30 Aug 25 10:53:28 lubuntu kernel: [ 367.920597] [<c1407d38>] dev_attr_show+0x18/0x40 Aug 25 10:53:28 lubuntu kernel: [ 367.920608] [<c11dad15>] sysfs_seq_show+0xe5/0x1c0 Aug 25 10:53:28 lubuntu kernel: [ 367.920621] [<c119846e>] seq_read+0xce/0x370 Aug 25 10:53:28 lubuntu kernel: [ 367.920633] [<c11983a0>] ? seq_hlist_next_percpu+0x90/0x90 Aug 25 10:53:28 lubuntu kernel: [ 367.920644] [<c1179238>] vfs_read+0x78/0x140 Aug 25 10:53:28 lubuntu kernel: [ 367.920654] [<c11799a9>] SyS_read+0x49/0x90 Aug 25 10:53:28 lubuntu kernel: [ 367.920667] [<c165efcd>] sysenter_do_call+0x12/0x28 /var/log/installer/debug shows upower related error: Ubiquity 2.18.8 Gtk-Message: Failed to load module "overlay-scrollbar" Gtk-Message: Failed to load module "overlay-scrollbar" ERROR:dbus.proxies:Introspect error on :1.23:/org/freedesktop/UPower: dbus.exceptions.DBusException: org.freedesktop.DBus.Error.NoReply: Did not receive a reply. Possible causes include: the remote application did not send a reply, the message bus security policy blocked the reply, the reply timeout expired, or the network connection was broken. Exception in GTK frontend (invoking crash handler): Traceback (most recent call last): File "/usr/lib/ubiquity/bin/ubiquity", line 636, in <module> main(oem_config) File "/usr/lib/ubiquity/bin/ubiquity", line 622, in main install(query=options.query) File "/usr/lib/ubiquity/bin/ubiquity", line 260, in install wizard = ui.Wizard(distro) File "/usr/lib/ubiquity/ubiquity/frontend/gtk_ui.py", line 290, in __init__ mod.ui = mod.ui_class(mod.controller) File "/usr/lib/ubiquity/plugins/ubi-prepare.py", line 93, in __init__ upower.setup_power_watch(self.prepare_power_source) File "/usr/lib/ubiquity/ubiquity/upower.py", line 21, in setup_power_watch power_state_changed() File "/usr/lib/ubiquity/ubiquity/upower.py", line 18, in power_state_changed not misc.get_prop(upower, UPOWER_PATH, 'OnBattery')) File "/usr/lib/ubiquity/ubiquity/misc.py", line 809, in get_prop return obj.Get(iface, prop, dbus_interface=dbus.PROPERTIES_IFACE) File "/usr/lib/python3/dist-packages/dbus/proxies.py", line 70, in __call__ return self._proxy_method(*args, **keywords) File "/usr/lib/python3/dist-packages/dbus/proxies.py", line 145, in __call__ **keywords) File "/usr/lib/python3/dist-packages/dbus/connection.py", line 651, in call_blocking message, timeout)

    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

  • C++'s char * by swig got problem in Python 3.0

    - by gpliu3
    Our C++ lib works fine with Python2.4 using Swig, returning a C++ char* back to a python str. But this solution hit problem in Python3.0, error is: Exception=(, UnicodeDecodeError('utf8', b"\xb6\x9d\xa.....",0, 1, 'unexpected code byte') Our definition is like(working fine in Python 2.4): void cGetPubModulus( void* pSslRsa, char* cMod, int* nLen ); %include "cstring.i" %cstring_output_withsize( char* cMod, int* nLen ); Suspect swig is doing a Bytes-Str conversion automatically. In python2.4 it can be implicit but in Python3.0 it's no long allowed.. Anyone got a good idea? thanks

    Read the article

  • Python 3.1 books still directly applicable to learning Python 2.7?

    - by jaysun
    I need to learn Python (v2.7) for my job, and looking for the best intro book for professional programmers. I found (via amazon) that "The Quick Python Book" is the best, but it's for Python 3.1 I know there's a lot of similarities in 2.7 and 3.1, and somewhere read that you can mostly use 3.1 syntax in 2.7 as a good "future practice". Can someone with experience please verify that a book for learning Python3 would still be directly applicable for 2.7? Thank you very much. edit: "The Quick Python Book" is for 3.1

    Read the article

  • How can I select which Java to use?

    - by user6611
    I have installed both OpenJDK 6 and 7. When I run "java somefile" from the command line, OpenJDK 6 is invoked. I do not want to change this default behavior. What command can I use to run my non-default OpenJDK 7 installation instead? (I am used to running "python somefile" to invoke the default Python, "python2.7 somefile" to use Python 2.7 specifically and "python3 somefile" to use Python 3 specifically.)

    Read the article

  • Ubuntu 12.10 upgrade stopped halfway through

    - by Mike
    While upgrading from 12.04 to 12.10 the upgrade crashed while installing the upgrades. It stopped while "configuring python3-aptdaemon.gtk3widgets" and the terminal says flashplugin-installer: downloading then shows the url for the flash plugin that its downloading. I think it stopped working because my internet connection is a bit patchy, and it probably failed while downloading the installer, but what can I do to make it get going again?

    Read the article

  • Python 3.0 IDE - Komodo and Eclipse both flaky?

    - by victorhooi
    heya, I'm trying to find a decent IDE that supports Python 3.x, and offers code completion/in-built Pydocs viewer, Mercurial integration, and SSH/SFTP support. Anyhow, I'm trying Pydev, and I open up a .py file, it's in the Pydev perspective and the Run As doesn't offer any options. It does when you start a Pydev project, but I don't want to start a project just to edit one single Python script, lol, I want to just open a .py file and have It Just Work... Plan 2, I try Komodo 6 Alpha 2. I actually quite like Komodo, and it's nice and snappy, offers in-built Mercurial support, as well as in-built SSH support (although it lacks SSH HTTP Proxy support, which is slightly annoying). However, for some reason, this refuses to pick up Python 3. In Edit-Preferences-Languages, there's two option, one for Python and Python3, but the Python3 one refuses to work, with either the official Python.org binaries, or ActiveState's own ActivePython 3. Of course, I can set the "Python" interpreter to the 3.1 binary, but that's an ugly hack and breaks Python 2.x support. So, does anybody who uses an IDE for Python have any suggestions on either of these accounts, or can you recommend an alternate IDE for Python 3.0 development? Cheers, Victor

    Read the article

  • "ImportError: cannot import name Exchange" when using Celery w/ Kombu installed

    - by alukach
    I'm trying to create a Celery worker node on an Amazon EC2 Windows2008 R2 instance. Due to a plugin we require for another Python module, we are required to user Python3. I've installed Python3.2 and necessary modules and run Celery, but for some reason it states that it can't import Exchange and Queue from Kombu, despite the face that Kombu is installed and can be imported by python. Microsoft Windows [Version 6.1.7601] Copyright (c) 2009 Microsoft Corporation. All rights reserved. C:\Users\Administrator>celery Traceback (most recent call last): File "C:\Python32\Scripts\celery-script.py", line 9, in <module> load_entry_point('celery==3.0.11', 'console_scripts', 'celery')() File "C:\Python32\lib\site-packages\celery\__main__.py", line 13, in main from celery.bin.celery import main File "C:\Python32\lib\site-packages\celery\bin\celery.py", line 21, in <module> from celery.utils import term File "C:\Python32\lib\site-packages\celery\utils\__init__.py", line 22, in <module> from kombu import Exchange, Queue ImportError: cannot import name Exchange C:\Users\Administrator>python Python 3.2 (r32:88445, Feb 20 2011, 21:29:02) [MSC v.1500 32 bit (Intel)] on win32 Type "help", "copyright", "credits" or "license" for more information. >>> from kombu import Exchange, Queue >>> print('WTF?!?') WTF?!? >>> This problem seems similar to this and this, but I have not been able to remedy the issue. Any ideas?

    Read the article

  • Compile latest blender on ubuntu 12.0464bit?

    - by gabriel
    What i want is to compile latest blender from SVN. I am using this guide My issues are: How can i install it with the final .deb created file and how can i give this package to a ppa! So, when i execute sudo apt-get update; sudo apt-get install subversion build-essential gettext \ libxi-dev libsndfile1-dev \ libpng12-dev libfftw3-dev \ libopenexr-dev libopenjpeg-dev \ libopenal-dev libalut-dev libvorbis-dev \ libglu1-mesa-dev libsdl1.2-dev libfreetype6-dev \ libtiff4-dev libavdevice-dev \ libavformat-dev libavutil-dev libavcodec-dev libjack-dev \ libswscale-dev libx264-dev libmp3lame-dev python3.2-dev \ libspnav-dev it gives me this The following packages have unmet dependencies: libjack-dev : Depends: libjack0 (= 1:0.121.0+svn4538-3ubuntu1) but it is not going to be installed E: Unable to correct problems, you have held broken packages. I know that skype does not allow the installation of those libraries. Thanks

    Read the article

  • USB-creator: Error erasing device: Unknown or unsupported erase type

    - by Mike Williamson
    I created a live usb using usb-creator-gtk. I installed Ubuntu with it and all was good with the world. Now I am trying to use the same memory stick and create a live USB for 14.04 and I get the following error when trying to erase the disk. org.freedesktop.DBus.Python.gi._glib.GError: Traceback (most recent call last): File "/usr/lib/python3/dist-packages/dbus/service.py", line 707, in _message_cb retval = candidate_method(self, *args, **keywords) File "/usr/share/usb-creator/usb-creator-helper", line 239, in Format block.call_format_sync('dos', GLib.Variant('a{sv}', {'erase': GLib.Variant('s', '')}), None) gi._glib.GError: GDBus.Error:org.freedesktop.UDisks2.Error.Failed: Error erasing device: Unknown or unsupported erase type `' How can I fix this so I can create a new live USB?

    Read the article

  • How to get rid of the background gradient of the inline GtkToolbar?

    - by Dima
    When you run the below code, it will show an inline toolbar in a window. Notice how the inline toolbar has a stand-out backbround. Is there a way to apply CSS to get rid of it and make blend with regular window color? #!/usr/bin/python3 from gi.repository import Gtk button_names = [Gtk.STOCK_ABOUT, Gtk.STOCK_ADD, Gtk.STOCK_REMOVE, Gtk.STOCK_QUIT] buttons = [Gtk.ToolButton.new_from_stock(name) for name in button_names] toolbar = Gtk.Toolbar() toolbar.set_show_arrow(False) for button in buttons: toolbar.insert(button, -1) style_context = toolbar.get_style_context() style_context.add_class(Gtk.STYLE_CLASS_INLINE_TOOLBAR) grid = Gtk.Grid() grid.add(toolbar) label = Gtk.Label() grid.add(label) window = Gtk.Window() window.set_size_request(200, 50) window.add(grid) window.connect('delete-event', Gtk.main_quit) window.show_all() Gtk.main()

    Read the article

  • Handling large integers in python [migrated]

    - by Sushma Palimar
    I had written a program in python to find b such that a prime number p divides b^2-8. The range for b is [1, (p+1)/2]. For small integers it works, say only up to 7 digits. But not for large integers, say for p = 140737471578113. I get the error message for i in range (2,p1,1): MemoryError I wrote the program as #!/usr/bin/python3 p=long(raw_input('enter the prime number:')) p1=long((p+1)/2) for i in range (2,p1,1): s = long((i*i)-8) if (s%p==0): print i

    Read the article

  • Mutable global variables don't get hide in python functions, right?

    - by aXqd
    Please see the following code: def good(): foo[0] = 9 # why this foo isn't local variable who hides the global one def bad(): foo = [9, 2, 3] # foo is local, who hides the global one for func in [good, bad]: foo = [1,2,3] print('Before "{}": {}'.format(func.__name__, foo)) func() print('After "{}": {}'.format(func.__name__, foo)) The result is as below: # python3 foo.py Before "good": [1, 2, 3] After "good": [9, 2, 3] Before "bad" : [1, 2, 3] After "bad" : [1, 2, 3]

    Read the article

  • /usr/bin/python Replacement

    - by tikiking1
    If I've changed the target of /usr/bin/python from /usr/bin/python2.7 to /usr/bin/python3.2 (I realize this was an ABSOUTELY HORRIBLE idea) in Ubuntu 12.04.1 LTS. Afterwards, several applications, including software-center and update-manager have stopped working. Insofar as I can tell, this is because they are written in Python2.7. I replaced the default /usr/bin/python shebang with the 2.7 one, and this fixes them on the application level. Switching /usr/bin/python back to /usr/bin/python2.7 really isn't an option, but is there a list of all applications installed by default in Ubuntu 12.04.1 LTS, if installed from a new CD-R, that use a shebang of #!/usr/bin/python instead of #!/usr/bin/pythonX.Y?

    Read the article

  • Terminal OS X Error when using Python

    - by Stephen
    Hey, I'm trying to learn how to program so I've installed the latest version of Python and I've been following the Byte of Python tutorial. I'm using Textwrangler I've only gotten as far as the simple "Hello World" intro and I'm already having a problem. I type out the code (just without the ""): "#!/usr/bin/python" "#Filename: helloworld.py" "print('Hello World')" and save it to my desktop as helloworld.py. I then go into terminal and type "python3 helloworld.py" and I get the following error message: /Library/Frameworks/Python.framework/Versions/3.1/Resources/Python.app/Contents/MacOS/Python: can't open file 'helloworld.py': [Errno 2] No such file or directory I was hoping someone could tell me what I'm doing wrong. If I choose to run the script from Textwrangler it operates just fine however I'm not able to access it from the Terminal. Thanks so much!

    Read the article

  • How to install PyQt on Mac OS X 10.6.

    - by Jebagnanadas
    Hello all, I'm quite new to Mac OS X. when i tried to install PyQt on Mac Os X after installing python 3.1, Qt 4.6.2 and SIP 4.10.1 i encounter the following error when i execute $python3 configure.py command. Determining the layout of your Qt installation... This is the GPL version of PyQt 4.7 (licensed under the GNU General Public License) for Python 3.1 on darwin. Type '2' to view the GPL v2 license. Type '3' to view the GPL v3 license. Type 'yes' to accept the terms of the license. Type 'no' to decline the terms of the license. Do you accept the terms of the license? yes Checking to see if the QtGui module should be built... Checking to see if the QtHelp module should be built... Checking to see if the QtMultimedia module should be built... Checking to see if the QtNetwork module should be built... Checking to see if the QtOpenGL module should be built... Checking to see if the QtScript module should be built... Checking to see if the QtScriptTools module should be built... Checking to see if the QtSql module should be built... Checking to see if the QtSvg module should be built... Checking to see if the QtTest module should be built... Checking to see if the QtWebKit module should be built... Checking to see if the QtXml module should be built... Checking to see if the QtXmlPatterns module should be built... Checking to see if the phonon module should be built... Checking to see if the QtAssistant module should be built... Checking to see if the QtDesigner module should be built... Qt v4.6.2 free edition is being used. Qt is built as a framework. SIP 4.10.1 is being used. The Qt header files are in /usr/include. The shared Qt libraries are in /Library/Frameworks. The Qt binaries are in /Developer/Tools/Qt. The Qt mkspecs directory is in /usr/local/Qt4.6. These PyQt modules will be built: QtCore. The PyQt Python package will be installed in /Library/Frameworks/Python.framework/Versions/3.1/lib/python3.1/site-packages. PyQt is being built with generated docstrings. PyQt is being built with 'protected' redefined as 'public'. The Designer plugin will be installed in /Developer/Applications/Qt/plugins/designer. The PyQt .sip files will be installed in /Library/Frameworks/Python.framework/Versions/3.1/share/sip/PyQt4. pyuic4, pyrcc4 and pylupdate4 will be installed in /Library/Frameworks/Python.framework/Versions/3.1/bin. Generating the C++ source for the QtCore module... sip: Usage: sip [-h] [-V] [-a file] [-b file] [-c dir] [-d file] [-e] [-g] [-I dir] [-j #] [-k] [-m file] [-o] [-p module] [-r] [-s suffix] [-t tag] [-w] [-x feature] [-z file] [file] Error: Unable to create the C++ code. Anybody here installed PyQt on Mac OS X 10.6.2 successfully.. Any help would be much appreciated.. Thanks in advance..

    Read the article

  • Removing broken packages on distro update (13.04 to 13.10)

    - by user203974
    i'm kinda new to linux. last night i tried upgrading from 13.04 to 13.10 but i got the "could not calculate" error. i read this question and found this error in the main log: Dist-upgrade failed: 'E:Unable to correct problems, you have held broken packages.' and here's a list of my broken packages : Broken libwayland-client0:amd64 Conflicts on libwayland0 [ amd64 ] < 1.0.5-0ubuntu1 > ( libs ) (< 1.1.0) Broken libpam-systemd:amd64 Conflicts on libpam-xdg-support [ amd64 ] < 0.2-0ubuntu2 > ( admin ) Broken cups-filters:amd64 Conflicts on ghostscript-cups [ amd64 ] < 9.07~dfsg2-0ubuntu3.1 > ( text ) Broken libharfbuzz0a:amd64 Breaks on libharfbuzz0 [ amd64 ] < 0.9.13-1 > ( libs ) Broken libunity-scopes-json-def-desktop:amd64 Conflicts on libunity-common [ amd64 ] < 6.90.2daily13.04.05-0ubuntu1 > ( gnome ) (< 7.0.7) Broken libunity-scopes-json-def-desktop:amd64 Conflicts on libunity-common [ i386 ] < none > ( none ) (< 7.0.7) Broken libaccount-plugin-generic-oauth:amd64 Conflicts on account-plugin-generic-oauth [ amd64 ] < 0.10bzr13.03.26-0ubuntu1.1 > ( gnome ) (< 0.10bzr13.04.30) Broken libaccount-plugin-generic-oauth:amd64 Breaks on account-plugin-generic-oauth [ amd64 ] < 0.10bzr13.03.26-0ubuntu1.1 > ( gnome ) (< 0.10bzr13.04.30) Broken python3-aptdaemon.pkcompat:amd64 Breaks on libpackagekit-glib2-14 [ amd64 ] < 0.7.6-3ubuntu1 > ( libs ) (<= 0.7.6-4) Broken libsnmp-base:amd64 Breaks on libsnmp15 [ amd64 ] < 5.4.3~dfsg-2.7ubuntu1 > ( libs ) (< 5.7.2~dfsg-5) Broken libunity-core-6.0-8:amd64 Conflicts on unity-common [ amd64 ] < 7.0.0daily13.06.19~13.04-0ubuntu1 > ( gnome ) Broken python3-uno:amd64 Conflicts on python-uno [ amd64 ] < 1:4.0.4-0ubuntu1 > ( python ) Broken unity-scope-home:amd64 Conflicts on unity-lens-shopping [ amd64 ] < 6.8.0daily13.03.04-0ubuntu1 > ( gnome ) Broken xserver-xorg-video-mach64:amd64 Depends on xorg-video-abi-13 [ amd64 ] < none > ( none ) Broken usb-modeswitch-data:amd64 Breaks on usb-modeswitch [ amd64 ] < 1.2.3+repack0-1ubuntu3 > ( comm ) (< 1.2.6) Broken unity-gtk2-module:amd64 Conflicts on appmenu-gtk [ amd64 ] < 12.10.3daily13.04.03-0ubuntu1 > ( libs ) Broken xserver-xorg-video-intel:amd64 Depends on xorg-video-abi-13 [ amd64 ] < none > ( none ) Broken xserver-xorg-video-r128:amd64 Depends on xorg-video-abi-13 [ amd64 ] < none > ( none ) Broken unity-gtk3-module:amd64 Conflicts on appmenu-gtk3 [ amd64 ] < 12.10.3daily13.04.03-0ubuntu1 > ( libs ) Broken xserver-xorg-video-nouveau:amd64 Depends on xorg-video-abi-13 [ amd64 ] < none > ( none ) Broken xserver-xorg-video-cirrus:amd64 Depends on xorg-video-abi-13 [ amd64 ] < none > ( none ) Broken libbamf3-1:amd64 Depends on bamfdaemon [ amd64 ] < 0.4.0daily13.06.19~13.04-0ubuntu1 -> 0.5.1+13.10.20131011-0ubuntu1 > ( libs ) (= 0.4.0daily13.06.19~13.04-0ubuntu1) Broken bzr-gtk:amd64 Depends on bzr [ amd64 ] < 2.6.0~bzr6571-4ubuntu2 -> 2.6.0-3ubuntu1 > ( devel ) (< 2.6.0) Broken libgphoto2-6-dev:amd64 Conflicts on libgphoto2-2-dev [ amd64 ] < 2.4.14-2 > ( libdevel ) Broken activity-log-manager:amd64 Conflicts on activity-log-manager-common [ amd64 ] < 0.9.4-0ubuntu6.2 > ( utils ) Broken libgjs0d:amd64 Conflicts on libgjs0c [ amd64 ] < 1.34.0-0ubuntu1 > ( libs ) Broken libgtksourceview-3.0-0:amd64 Depends on libgtksourceview-3.0-common [ amd64 ] < 3.6.3-0ubuntu1 -> 3.8.2-0ubuntu1 > ( libs ) (< 3.7) Broken gnome-pie:amd64 Depends on libbamf3-1 [ amd64 ] < 0.4.0daily13.06.19~13.04-0ubuntu1 > ( libs ) Broken libunity-core-6.0-5:amd64 Depends on unity-services [ amd64 ] < 7.0.0daily13.06.19~13.04-0ubuntu1 -> 7.1.2+13.10.20131014.1-0ubuntu1 > ( gnome ) (= 7.0.0daily13.06.19~13.04-0ubuntu1) Broken xserver-xorg-video-all:amd64 Depends on xserver-xorg-video-cirrus [ amd64 ] < 1:1.5.2+git20130108.e2bf5b25-0ubuntu0sarvatt > ( x11 ) Broken xserver-xorg-video-all:amd64 Depends on xserver-xorg-video-intel [ amd64 ] < 2:2.99.904+git20131009.b9ad5b62-0ubuntu0sarvatt~raring > ( x11 ) Broken xserver-xorg-video-all:amd64 Depends on xserver-xorg-video-nouveau [ amd64 ] < 1:1.0.9+git20130730.300c5a32-0ubuntu0sarvatt~raring > ( x11 ) Broken xserver-xorg-video-ati:amd64 Depends on xserver-xorg-video-r128 [ amd64 ] < 6.9.1+git20130104.24f28a78-0ubuntu0sarvatt > ( x11 ) Broken xserver-xorg-video-ati:amd64 Depends on xserver-xorg-video-mach64 [ amd64 ] < 6.9.4+git20130104.80e62cc1-0ubuntu0sarvatt > ( x11 ) Broken xserver-xorg-video-mach64:amd64 Depends on xorg-video-abi-13 [ amd64 ] < none > ( none ) Broken xserver-xorg-video-intel:amd64 Depends on xorg-video-abi-13 [ amd64 ] < none > ( none ) Broken xserver-xorg-video-r128:amd64 Depends on xorg-video-abi-13 [ amd64 ] < none > ( none ) Broken xserver-xorg-video-nouveau:amd64 Depends on xorg-video-abi-13 [ amd64 ] < none > ( none ) Broken xserver-xorg-video-cirrus:amd64 Depends on xorg-video-abi-13 [ amd64 ] < none > ( none ) Broken xserver-xorg-video-all:amd64 Depends on xserver-xorg-video-cirrus [ amd64 ] < 1:1.5.2+git20130108.e2bf5b25-0ubuntu0sarvatt > ( x11 ) Broken xserver-xorg-video-all:amd64 Depends on xserver-xorg-video-intel [ amd64 ] < 2:2.99.904+git20131009.b9ad5b62-0ubuntu0sarvatt~raring > ( x11 ) Broken xserver-xorg-video-all:amd64 Depends on xserver-xorg-video-nouveau [ amd64 ] < 1:1.0.9+git20130730.300c5a32-0ubuntu0sarvatt~raring > ( x11 ) Broken xserver-xorg-video-ati:amd64 Depends on xserver-xorg-video-r128 [ amd64 ] < 6.9.1+git20130104.24f28a78-0ubuntu0sarvatt > ( x11 ) Broken xserver-xorg-video-ati:amd64 Depends on xserver-xorg-video-mach64 [ amd64 ] < 6.9.4+git20130104.80e62cc1-0ubuntu0sarvatt > ( x11 ) Broken xserver-xorg-video-mach64:amd64 Depends on xorg-video-abi-13 [ amd64 ] < none > ( none ) Broken xserver-xorg-video-intel:amd64 Depends on xorg-video-abi-13 [ amd64 ] < none > ( none ) Broken xserver-xorg-video-r128:amd64 Depends on xorg-video-abi-13 [ amd64 ] < none > ( none ) Broken xserver-xorg-video-nouveau:amd64 Depends on xorg-video-abi-13 [ amd64 ] < none > ( none ) Broken xserver-xorg-video-cirrus:amd64 Depends on xorg-video-abi-13 [ amd64 ] < none > ( none ) Broken xserver-xorg-video-all:amd64 Depends on xserver-xorg-video-cirrus [ amd64 ] < 1:1.5.2+git20130108.e2bf5b25-0ubuntu0sarvatt > ( x11 ) Broken xserver-xorg-video-ati:amd64 Depends on xserver-xorg-video-r128 [ amd64 ] < 6.9.1+git20130104.24f28a78-0ubuntu0sarvatt > ( x11 ) Broken xserver-xorg-video-mach64:amd64 Depends on xorg-video-abi-13 [ amd64 ] < none > ( none ) Broken xserver-xorg-video-intel:amd64 Depends on xorg-video-abi-13 [ amd64 ] < none > ( none ) Broken xserver-xorg-video-r128:amd64 Depends on xorg-video-abi-13 [ amd64 ] < none > ( none ) Broken xserver-xorg-video-nouveau:amd64 Depends on xorg-video-abi-13 [ amd64 ] < none > ( none ) Broken xserver-xorg-video-cirrus:amd64 Depends on xorg-video-abi-13 [ amd64 ] < none > ( none ) Broken xserver-xorg-video-all:amd64 Depends on xserver-xorg-video-cirrus [ amd64 ] < 1:1.5.2+git20130108.e2bf5b25-0ubuntu0sarvatt > ( x11 ) Broken xserver-xorg-video-all:amd64 Depends on xserver-xorg-video-intel [ amd64 ] < 2:2.99.904+git20131009.b9ad5b62-0ubuntu0sarvatt~raring > ( x11 ) Broken xserver-xorg-video-all:amd64 Depends on xserver-xorg-video-nouveau [ amd64 ] < 1:1.0.9+git20130730.300c5a32-0ubuntu0sarvatt~raring > ( x11 ) Broken xserver-xorg-video-ati:amd64 Depends on xserver-xorg-video-r128 [ amd64 ] < 6.9.1+git20130104.24f28a78-0ubuntu0sarvatt > ( x11 ) Broken xserver-xorg-video-ati:amd64 Depends on xserver-xorg-video-mach64 [ amd64 ] < 6.9.4+git20130104.80e62cc1-0ubuntu0sarvatt > ( x11 ) Broken xserver-xorg-video-mach64:amd64 Depends on xorg-video-abi-13 [ amd64 ] < none > ( none ) Broken xserver-xorg-video-intel:amd64 Depends on xorg-video-abi-13 [ amd64 ] < none > ( none ) Broken xserver-xorg-video-r128:amd64 Depends on xorg-video-abi-13 [ amd64 ] < none > ( none ) Broken xserver-xorg-video-nouveau:amd64 Depends on xorg-video-abi-13 [ amd64 ] < none > ( none ) Broken xserver-xorg-video-cirrus:amd64 Depends on xorg-video-abi-13 [ amd64 ] < none > ( none ) Broken xserver-xorg-video-all:amd64 Depends on xserver-xorg-video-cirrus [ amd64 ] < 1:1.5.2+git20130108.e2bf5b25-0ubuntu0sarvatt > ( x11 ) Broken xserver-xorg-video-all:amd64 Depends on xserver-xorg-video-intel [ amd64 ] < 2:2.99.904+git20131009.b9ad5b62-0ubuntu0sarvatt~raring > ( x11 ) Broken xserver-xorg-video-all:amd64 Depends on xserver-xorg-video-nouveau [ amd64 ] < 1:1.0.9+git20130730.300c5a32-0ubuntu0sarvatt~raring > ( x11 ) Broken xserver-xorg-video-ati:amd64 Depends on xserver-xorg-video-r128 [ amd64 ] < 6.9.1+git20130104.24f28a78-0ubuntu0sarvatt > ( x11 ) Broken xserver-xorg-video-ati:amd64 Depends on xserver-xorg-video-mach64 [ amd64 ] < 6.9.4+git20130104.80e62cc1-0ubuntu0sarvatt > ( x11 ) Broken xserver-xorg-video-mach64:amd64 Depends on xorg-video-abi-13 [ amd64 ] < none > ( none ) Broken xserver-xorg-video-intel:amd64 Depends on xorg-video-abi-13 [ amd64 ] < none > ( none ) Broken libxi6:amd64 Breaks on xserver-xorg-core [ amd64 ] < 2:1.13.4~git20130508+server-1.13-branch.10c42f57-0ubuntu0ricotz~raring -> 2:1.14.3-3ubuntu2 > ( x11 ) (< 2:1.14) Broken xserver-xorg-video-ati:amd64 Depends on xserver-xorg-video-mach64 [ amd64 ] < 6.9.4+git20130104.80e62cc1-0ubuntu0sarvatt > ( x11 ) Broken xserver-xorg-video-intel:amd64 Depends on xorg-video-abi-13 [ amd64 ] < none > ( none ) Broken xserver-xorg-video-r128:amd64 Depends on xorg-video-abi-13 [ amd64 ] < none > ( none ) Broken xserver-xorg-video-nouveau:amd64 Depends on xorg-video-abi-13 [ amd64 ] < none > ( none ) Broken xserver-xorg-video-cirrus:amd64 Depends on xorg-video-abi-13 [ amd64 ] < none > ( none ) Broken xserver-xorg-video-all:amd64 Depends on xserver-xorg-video-ati [ amd64 ] < 1:7.1.99+git20130730.6a278369-0ubuntu0sarvatt~raring -> 1:7.2.0-0ubuntu10 > ( x11 ) Broken xserver-xorg-video-all:amd64 Depends on xserver-xorg-video-cirrus [ amd64 ] < 1:1.5.2+git20130108.e2bf5b25-0ubuntu0sarvatt > ( x11 ) Broken xserver-xorg-video-all:amd64 Depends on xserver-xorg-video-intel [ amd64 ] < 2:2.99.904+git20131009.b9ad5b62-0ubuntu0sarvatt~raring > ( x11 ) Broken xserver-xorg-video-all:amd64 Depends on xserver-xorg-video-nouveau [ amd64 ] < 1:1.0.9+git20130730.300c5a32-0ubuntu0sarvatt~raring > ( x11 ) Broken xserver-xorg-video-ati:amd64 Depends on xorg-video-abi-13 [ amd64 ] < none > ( none ) Broken xserver-xorg-video-all:amd64 Depends on xserver-xorg-video-ati [ amd64 ] < 1:7.1.99+git20130730.6a278369-0ubuntu0sarvatt~raring -> 1:7.2.0-0ubuntu10 > ( x11 ) Broken xserver-xorg-video-all:amd64 Depends on xserver-xorg-video-cirrus [ amd64 ] < 1:1.5.2+git20130108.e2bf5b25-0ubuntu0sarvatt > ( x11 ) Broken xserver-xorg-video-all:amd64 Depends on xserver-xorg-video-intel [ amd64 ] < 2:2.99.904+git20131009.b9ad5b62-0ubuntu0sarvatt~raring > ( x11 ) Broken xserver-xorg-video-all:amd64 Depends on xserver-xorg-video-nouveau [ amd64 ] < 1:1.0.9+git20130730.300c5a32-0ubuntu0sarvatt~raring > ( x11 ) thats a lot of stuff ... do i have to remove them one by one ? will removing them caues any issue ? do i have to install them one by one again after the upgrade ?

    Read the article

  • How come string.maketrans does not work in Python 3.1?

    - by ShaChris23
    I'm a Python newbie. How come this doesn't work in Python 3.1? from string import maketrans # Required to call maketrans function. intab = "aeiou" outtab = "12345" trantab = maketrans(intab, outtab) str = "this is string example....wow!!!"; print str.translate(trantab); When I executed the above code, I get the following instead: Traceback (most recent call last): File "<pyshell#119>", line 1, in <module> transtab = maketrans(intab, outtab) File "/Library/Frameworks/Python.framework/Versions/3.1/lib/python3.1/string.py", line 60, in maketrans raise TypeError("maketrans arguments must be bytes objects") TypeError: maketrans arguments must be bytes objects What does "must be bytes objects" mean? Could anyone please help post a working code for Python 3.1 if it's possible?

    Read the article

  • Python 2.6, 3 abstract base class misunderstanding

    - by Aaron
    I'm not seeing what I expect when I use ABCMeta and abstractmethod. This works fine in python3: from abc import ABCMeta, abstractmethod class Super(metaclass=ABCMeta): @abstractmethod def method(self): pass a = Super() TypeError: Can't instantiate abstract class Super ... And in 2.6: class Super(): __metaclass__ = ABCMeta @abstractmethod def method(self): pass a = Super() TypeError: Can't instantiate abstract class Super ... They both also work fine (I get the expected exception) if I derive Super from object, in addition to ABCMeta. They both "fail" (no exception raised) if I derive Super from list. I want an abstract base class to be a list but abstract, and concrete in sub classes. Am I doing it wrong, or should I not want this in python?

    Read the article

  • Python 3 - Module: subprocess

    - by Rhys
    Hi Stack Overflow users, I've encountered a frustrating problem, can't find the answer to it. Yesterday I was trying to find a way to HIDE a subprocess.Popen. So for example, if i was opening the cmd. I would like it to be hidden, permanently. I found this code: kwargs = {} if subprocess.mswindows: su = subprocess.STARTUPINFO() su.dwFlags |= subprocess.STARTF_USESHOWWINDOW su.wShowWindow = subprocess.SW_HIDE kwargs['startupinfo'] = su subprocess.Popen("cmd.exe", **kwargs) It worked like a charm! But today, for reasons I don't need to get into, I had to reinstall python 3 (32bit) Now, when I run my program I get this error: Traceback (most recent call last): File "C:\Python31\hello.py", line 7, in <module> su.dwFlags |= subprocess.STARTF_USESHOWWINDOW AttributeError: 'module' object has no attribute 'STARTF_USESHOWWINDOW' I'm using 32bit, python3.1.3 ... just like before. If you have any clues/alternatives PLEASE post, thanks. NOTE: I am looking for a SHORT method to hide the app, not like two pages of code please

    Read the article

< Previous Page | 1 2 3 4  | Next Page >