bug in python/numarray
Hi, there, I got different results by running the same lines of code on windows and debian. Here is the code: a = kroneckerproduct(ones((4195,1)), identity(12)) print a.mean() This works perfectly well in windows but it gave the following error while running it in debian: Traceback (most recent call last): File "", line 1, in ? File "/usr/lib/python2.4/site-packages/numarray/numarraycore.py", line 1137, in mean return self.sum()/(self.nelements()*1.0) File "/usr/lib/python2.4/site-packages/numarray/numarraycore.py", line 1133, in sum return ufunc.add.reduce(ufunc.add.areduce(self, type=type).flat, type=type) IndexError: too many indices. But if I reduce the number 4195 to 419, it works. Is it a bug in Python or Numarray? Can someone help me figure it out? BTW, the python version is 2.4.1 Many thanks! Xiangyi -- http://mail.python.org/mailman/listinfo/python-list
Cloud platform with GPU
Good day all, I am looking for a good cloud platform to do all my python development for machine learning with GPU availability, so far I have used Amazon ec2, google colab, kaggle etc but none of them was very satisfactory. Anyone has good experience with other options? please share and TIA Denis -- https://mail.python.org/mailman/listinfo/python-list
Are there something like "Effective Python"?
Hi all, I just finished reading Learning Python 3rd ed, and am doing my first Python application, which retrieves and process text and XML documents from Web. Python helped me to write the application in a few hours, I'm very happy with its productivity. But the performance is not satisfactory. I decide to optimized it in Python before trying C/C++ extensions. But I don't know Python much and have no clu to tune my program. Also, I don't know what Pythonist's preferred styles. Are there any books/documents which play the similar role for Python as 'Effective C++' does for C++? For example, one of my friends read my program and suggest me to move the re.compile() out of a for-loop, since the regular pattern is fixed, and re.compile() is slow. I want to find more such advice, where can I find them? Thank you. Mike -- http://mail.python.org/mailman/listinfo/python-list
Re: Are there something like "Effective Python"?
Bart, I'm sorry, it's 2nd edtion. Thanks. mike BartlebyScrivener 写道: > >> I just finished reading Learning Python 3rd ed, > > For real? I thought there was only a 2nd edition. > > http://www.oreilly.com/catalog/lpython2/ -- http://mail.python.org/mailman/listinfo/python-list
[twisted] PyOpenSSL and PyCrypto are outdated!
Hi all, I'm learning Twisted and downloaded pyOpenSSL and pycrypto win32 installer on http://twisted.sourceforge.net/contrib/ . But I find the lastest version are for Python 2.3. I try to rebuild pyOpenSSL from source, but get lots of compile errors. Are these two packages obsolated? Where can I find updated version? Thank you in advance. -- http://mail.python.org/mailman/listinfo/python-list
Re: PyOpenSSL and PyCrypto are outdated!
Thank you Terry. I searched but didn't get useful information. In fact, I've built pycrypto 2.0.1 successfully. However, the source of pyOpenSSL seemed to be incompatible with lastest OpenSSL 0.98b. I tried to build it and got dozens of compile errors which complain about syntax error in x509v3.h. My C++ compiler is Visual C++ 7.1. Should I use older OpenSSL release? Terry Reedy 写道: > "Mike Meng" <[EMAIL PROTECTED]> wrote in message > news:[EMAIL PROTECTED] > > >I'm learning Twisted and downloaded pyOpenSSL and pycrypto win32 > > installer on http://twisted.sourceforge.net/contrib/ . But I find the > > lastest version are for Python 2.3. I try to rebuild pyOpenSSL from > > source, but get lots of compile errors. Are these two packages > > obsolated? Where can I find updated version? > > Did you try Google? This question has been asked before. -- http://mail.python.org/mailman/listinfo/python-list
Socket Error : Address still in use (Conveting from python 1.5.2 to 2.7.1)
Hello there, I am in the midst of converting my application from python 1.5.2 to python 2.7.1 on HP-UX 11 Itanium box. My application server will set a listening port, accepting request from multiple clients. The code just works fine in the old python environment. E.g. when I do a lsof | grep I got the following. python 62602 genasm5u IPv4 0x7350d1f00t0 TCP zmy02aix02:12121 (LISTEN) python 62602 genasm6u IPv4 0x744fb5f00t0 TCP zmy02aix02:12121->zmy02aix02-bkup:51867 (ESTABLISHED) python 62602 genasm7u IPv4 0x75b959f00t0 TCP zmy02aix02:12121->zmy02aix02-bkup:51869 (ESTABLISHED) python 62602 genasm8u IPv4 0x75a559f00t0 TCP zmy02aix02:12121->zmy02aix02-bkup:51873 (ESTABLISHED) Strange things happened in python 2.7.1. Without modifying the code of how the socket was created and how the TCP/IP address was bound to the socket, it seems that every other processes that I run, which supposed to connect to the listening port as a client program, also appears to be holding a listening port. This is weird. Anyone has encountered this before especially when you were converting from an old python to a new python? Like you can see below there are 5 processes hosting the listening port of 18882. $ lsof -i tcp | grep 18882 python 10598 r328133u IPv4 0xe0050b73e400 0t0 TCP zmy02hp3.ap.freescale.net:18882 (LISTEN) python 18181 r328133u IPv4 0xe0050b73e400 0t0 TCP zmy02hp3.ap.freescale.net:18882 (LISTEN) python 20025 r328133u IPv4 0xe0050b73e400 0t0 TCP zmy02hp3.ap.freescale.net:18882 (LISTEN) python 26295 r328133u IPv4 0xe0050b73e400 0t0 TCP zmy02hp3.ap.freescale.net:18882 (LISTEN) python 26428 r328133u IPv4 0xe0050b73e400 0t0 TCP zmy02hp3.ap.freescale.net:18882 (LISTEN) Since only one of them is the genuine process holding the port, I need to kill off the rest of the process if I need to restart the genuine process running under that port. It should not work this way. Here is the code of the application process that hosts the listening port. self.sock = socket.socket( socket.AF_INET, socket.SOCK_STREAM ) self.sock.setsockopt( socket.SOL_SOCKET, socket.SO_REUSEADDR, 1 ) self.sock.setsockopt( socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1 self.sock.setsockopt( socket.IPPROTO_TCP, _TCP_NODELAY, 1 ) self.sock.bind( self.server_address ) Here is the client code that does the connection. self.sock = socket.socket( socket.AF_INET, socket.SOCK_STREAM ) self.sock.setsockopt( socket.IPPROTO_TCP, _TCP_NODELAY, 1 ) self.sock.connect( self.server_address ) Regards, Wah Meng -- http://mail.python.org/mailman/listinfo/python-list
Python 2.7.1 64-bit Build on HP-UX11.31 ia64 with aCC - Many modules failed to build
Hello there, I have posted this in Compiler SIG and re-post here in case anyone who knows about this issue is not subscribed to that group. I am working on python build on my server using HP-UX ANSI C Compiler. I want to be consistent using aCC throughout instead of gcc for my python and cx_Oracle build as Oracle is not supporting gcc build much. Here is my aCC version. # swlist -l product | grep Compiler ACXX C.06.26.EVAL HP C/aC++ Compiler C-ANSI-C C.06.26.EVAL HP C/aC++ Compiler COMPLIBS B.11.31Compiler Support Libraries Anyhow, my issue now is when I am building my python in 64-bit, I am encountering many modules failed to build issue, despite the python executable is successfully built. There are just so many modules that failed, that I would conclude my build failed. :P I followed through the instruction in README file for 64-bit build using HP-UX compiler (--without-gcc option is used in configure). I exported and unexported the environment variables before configure and make is run, respectively. I also removed -O option in the Makefile before running make. I have a few questions. 1.) Why Makefile is re-generated after python executable is created? I noticed the removal of optimization flag in Makefile is gone/restored after python binary is generated. 2.) 64-bit option. It seems that this is a bad flag that linker doesn't recognize? Many important modules failed to build, and I believe its due to this error. When I manually execute ld without passing in +DD64 flag, the module is generated successfull. ld -b +DD64 -lxnet build/temp.hp-ux-B.11.31-ia64-2.7/home/r32813/Build/2.7.1/Python-2.7.1/Modules/mathmodule.o build/temp.hp-ux-B.11.31-ia64-2.7/home/r32813/Build/2.7.1/Python-2.7.1/Modules/_math.o -L/usr/local/lib -lm -o build/lib.hp-ux-B.11.31-ia64-2.7/math.so ld: Unrecognized argument: +DD64 Fatal error. Above is just showing one of the modules that failed to build. 3.) Built in modules, I see the compiler cannot find the bit of information required to build _tkinter module. How do I make the configure able to locate my tcl/tk source code or binary which I have already installed and built separately (and successfully)? So, where do I place the source code if I need to put it so that the compiler can find? To end my question, here is the outcome of my build. For build in modules, I just need my _tkinter running. For shared libraries, I think need most of them, those are the basic functions that my application calls. Thanks in advance for your reply. Python build finished, but the necessary bits to build these modules were not found: _bsddb _curses_curses_panel _sqlite3 _ssl _tkinter bsddb185 bz2dl gdbm imageoplinuxaudiodev ossaudiodevreadline spwd sunaudiodevzlib To find the necessary bits, look in setup.py in detect_modules() for the module's name. Failed to build these modules: _bisect_codecs_cn _codecs_hk _codecs_iso2022_codecs_jp _codecs_kr _codecs_tw _collections _csv _ctypes_ctypes_test _elementtree _functools _heapq _hotshot _io_json _locale _lsprof_md5 _multibytecodec _multiprocessing _random_sha _socket_struct_testcapi array audioopbinascii cmath cPicklecrypt cStringIO datetime dbm fcntl future_builtinsgrp itertools math mmap nisoperator parser pyexpatresource select strop syslog termios time unicodedata -- http://mail.python.org/mailman/listinfo/python-list
Error 'module' object has no attribute "_extension_registry" when cPickle is imported from an installed Python 2.7.1
Hello all, I encounter this issue whereby I am not able to load cPickle module into the python I newly built. There is no issue when I load it right from the folder where the python executable and libpython2.7.so is built. However, it gives me this error when I load the same module using the installed files (python and all its modules, shared library from default /use/local folder that contains bin, lib, include sub-folders) from "make install" command. Does anyone know why? Here is the error:- $ python Python 2.7.1 (r271:86832, Sep 27 2011, 15:19:26) [C] on hp-ux11 Type "help", "copyright", "credits" or "license" for more information. >>> import cPickle Traceback (most recent call last): File "", line 1, in AttributeError: 'module' object has no attribute '_extension_registry' -- http://mail.python.org/mailman/listinfo/python-list
Error 'No module named _sha256' when importing random in python 2.7.1
I just built python 2.7.1 on my HP Itanium 64-bit platform, using aCC. I encountered following issue when importing the random module. Does anyone know why am I getting this error? Thanks in advance for your reply. $ python Python 2.7.1 (r271:86832, Sep 27 2011, 15:19:26) [C] on hp-ux11 Type "help", "copyright", "credits" or "license" for more information. >>> import random Traceback (most recent call last): File "", line 1, in File "random.py", line 49, in import hashlib as _hashlib File "hashlib.py", line 136, in globals()[__func_name] = __get_hash(__func_name) File "hashlib.py", line 74, in __get_builtin_constructor import _sha256 ImportError: No module named _sha256 >>> -- http://mail.python.org/mailman/listinfo/python-list
RE: Error 'No module named _sha256' when importing random in python 2.7.1
Yes I did. In fact earlier "make test" failed to execute due to _sha256 not found in one of the module testing. Earlier I ignored these failures from the build and make test as I thought they are not needed by my application. Now I can't use "random" module in my application. So I need to solve this issue. Here is the output of the build. Python build finished, but the necessary bits to build these modules were not found: _bsddb _curses_curses_panel _sqlite3 _ssl bsddb185 bz2dl gdbm imageoplinuxaudiodev ossaudiodev readline spwd sunaudiodev zlib To find the necessary bits, look in setup.py in detect_modules() for the module's name. Failed to build these modules: _ctypestermios Regards, Wah Meng -Original Message- From: ch...@rebertia.com [mailto:ch...@rebertia.com] On Behalf Of Chris Rebert Sent: Tuesday, September 27, 2011 5:52 PM To: Wong Wah Meng-R32813 Cc: python-list@python.org Subject: Re: Error 'No module named _sha256' when importing random in python 2.7.1 On Tue, Sep 27, 2011 at 2:28 AM, Wong Wah Meng-R32813 wrote: > I just built python 2.7.1 on my HP Itanium 64-bit platform, using aCC. I > encountered following issue when importing the random module. Does anyone > know why am I getting this error? Thanks in advance for your reply. > File "hashlib.py", line 74, in __get_builtin_constructor > import _sha256 > ImportError: No module named _sha256 Did you get a message along the lines of "Python build finished, but the necessary bits to build these modules were not found:" when you built Python? Cheers, Chris -- http://mail.python.org/mailman/listinfo/python-list
RE: Error 'module' object has no attribute "_extension_registry" when cPickle is imported from an installed Python 2.7.1
Thanks Gabriel, Indeed, there is corrupted copy_reg.py file residing in my $PYTHONPATH folder, as opposed to the standard one from the installed package. Thanks a lot for your helps! Regards, Wah Meng -Original Message- From: python-list-bounces+wahmeng=freescale@python.org [mailto:python-list-bounces+wahmeng=freescale@python.org] On Behalf Of Gabriel Genellina Sent: Wednesday, September 28, 2011 7:53 AM To: python-list@python.org Subject: Re: Error 'module' object has no attribute "_extension_registry" when cPickle is imported from an installed Python 2.7.1 En Tue, 27 Sep 2011 06:08:54 -0300, Wong Wah Meng-R32813 escribió: > Hello all, > > I encounter this issue whereby I am not able to load cPickle module into > the python I newly built. There is no issue when I load it right from > the folder where the python executable and libpython2.7.so is built. > However, it gives me this error when I load the same module using the > installed files (python and all its modules, shared library from default > /use/local folder that contains bin, lib, include sub-folders) from > "make install" command. > > Does anyone know why? Here is the error:- > > $ python > Python 2.7.1 (r271:86832, Sep 27 2011, 15:19:26) [C] on hp-ux11 > Type "help", "copyright", "credits" or "license" for more information. >>>> import cPickle > Traceback (most recent call last): > File "", line 1, in > AttributeError: 'module' object has no attribute '_extension_registry' Looking at cPickle.c, it imports the copy_reg module and then looks for its "_extension_registry" attribute. Maybe your copy_reg.py is broken, or you have another copy_reg.py hiding the standard one. -- Gabriel Genellina -- http://mail.python.org/mailman/listinfo/python-list -- http://mail.python.org/mailman/listinfo/python-list
python 2.7.1 built not supporting thread?
Hello there, I couldn't detect this problem until I run my application that utilizes thread module in python that I just built on HP-UX 11.31 ia64 using aCC. Could it be the build did not include enable thread option? _REENTRANT as stated in the README file? If yes, it looks like threading may not work "out of the box". >>> thread.start_new_thread(testing, ()) Traceback (most recent call last): File "", line 1, in thread.error: can't start new thread >>> Excerpts from README file for python 2.7 build HP-UX: When using threading, you may have to add -D_REENTRANT to the OPT variable in the top-level Makefile; reported by Pat Knight, this seems to make a difference (at least for HP-UX 10.20) even though pyconfig.h defines it. This seems unnecessary when using HP/UX 11 and later - threading seems to work "out of the box". -- http://mail.python.org/mailman/listinfo/python-list
RE: python 2.7.1 HP-UX 11 ia64 built not supporting thread
Hello there, I included --with-threads option into the configure script calling, which it failed to add the -D_REENTRANT into Makefile. So I manually added this into OPT of the Makefile. I ran make again and generated a new python binary. However, the new binary is still not able to start a new thread from the thread module. I reviewed the config.log file, I think this failure has caused the build with threads failed. Cthreads.h header file is missing. Should this be included in my HP UX Compiler or it comes from python source? In python source I only found pythread.h. Anyway, I am only guessing what is wrong. Hope to hear some feedback here, whether this is something missing or a bug. configure:8407: checking for --with-threads configure:8427: result: yes configure:8484: checking for _POSIX_THREADS in unistd.h configure:8503: result: yes configure:8508: checking cthreads.h usability configure:8508: cc +DD64 -I/home/r32813/local/include -c -g conftest.c >&5 "conftest.c", line 128: error #3696-D: cannot open source file "cthreads.h" #include ^ 1 error detected in the compilation of "conftest.c". | #define HAVE_LIBDLD 1 | #define _REENTRANT 1 | /* end confdefs.h. */ | #include configure:8508: result: no configure:8508: checking for cthreads.h configure:8508: result: no configure:8521: checking mach/cthreads.h usability configure:8521: cc +DD64 -I/home/r32813/local/include -c -g conftest.c >&5 "conftest.c", line 128: error #3696-D: cannot open source file "mach/cthreads.h" #include ^ 1 error detected in the compilation of "conftest.c". configure:8521: $? = 2 configure: failed program was: | /* confdefs.h */ | #define _GNU_SOURCE 1 | #define HAVE_LIBDLD 1 | #define _REENTRANT 1 | /* end confdefs.h. */ | #include configure:8521: result: no configure:8521: checking for mach/cthreads.h configure:8521: result: no configure:8533: checking for --with-pth configure:8548: result: no configure:8556: checking for pthread_create in -lpthread configure:8572: cc +DD64 -I/home/r32813/local/include -o conftest -g -L/home/r32813/local/lib -L/home/r32813/Build/2.7.1/Python-2.7.1 conftest.c -l nsl -lrt -ldld -ldl -lpthread >&5 Regards, Wah Meng Genesis Wafermap Support Ticket: To report a problem: http://dyno.freescale.net/Question/QuestionMain3.asp?location=zmy02&category=&tickettype=6820 To request a service: http://dyno.freescale.net/Question/Questionmain3.asp?location=74&category=2&tickettype=6819 Or if it is related to EWM or DSA: http://dyno.freescale.net/Question/Questionmain3.asp?location=ZMY02&tickettype=6539 -Original Message- From: Wong Wah Meng-R32813 Sent: Wednesday, September 28, 2011 4:37 PM To: python-list@python.org Subject: python 2.7.1 built not supporting thread? Hello there, I couldn't detect this problem until I run my application that utilizes thread module in python that I just built on HP-UX 11.31 ia64 using aCC. Could it be the build did not include enable thread option? _REENTRANT as stated in the README file? If yes, it looks like threading may not work "out of the box". >>> thread.start_new_thread(testing, ()) Traceback (most recent call last): File "", line 1, in thread.error: can't start new thread >>> Excerpts from README file for python 2.7 build HP-UX: When using threading, you may have to add -D_REENTRANT to the OPT variable in the top-level Makefile; reported by Pat Knight, this seems to make a difference (at least for HP-UX 10.20) even though pyconfig.h defines it. This seems unnecessary when using HP/UX 11 and later - threading seems to work "out of the box". -- http://mail.python.org/mailman/listinfo/python-list
Python Migration Error: TypeError: exceptions must be old-style classes or derived from BaseException, not str
Hello guys, I am migrating my application from python 1.5.2 to 2.7.1. I encountered an error when I run some commands (I put in debug statement however, not able to trace down to which line of code that cause it to generate a lot of messages in one second until my hard disk space is full. The error log I got in my log file is as below:- Oct 3 14:12:41 ('Encountered exception while processing from', (0, '\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00'), , TypeError('exceptions must be old-style classes or derived from BaseException, not str',)) Does it mean in newer python I need to migrate all my Exception to non-string based exception type? That's should be a lot of changes. :p Regards, Wah Meng -- http://mail.python.org/mailman/listinfo/python-list
RE: Python Migration Error: TypeError: exceptions must be old-style classes or derived from BaseException, not str
Noted. No choice then, I will convert all my raise statement to use the exception instance. Thanks! Regards, Wah Meng -Original Message- From: ch...@rebertia.com [mailto:ch...@rebertia.com] On Behalf Of Chris Rebert Sent: Monday, October 03, 2011 3:46 PM To: Wong Wah Meng-R32813 Cc: python-list@python.org Subject: Re: Python Migration Error: TypeError: exceptions must be old-style classes or derived from BaseException, not str On Sun, Oct 2, 2011 at 11:45 PM, Wong Wah Meng-R32813 wrote: > Hello guys, > > I am migrating my application from python 1.5.2 to 2.7.1. I encountered an > error when I run some commands (I put in debug statement however, not able to > trace down to which line of code that cause it to generate a lot of messages > in one second until my hard disk space is full. The error log I got in my log > file is as below:- > > Oct 3 14:12:41 ('Encountered exception while processing from', (0, > '\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00'), 'exceptions.TypeError'>, TypeError('exceptions must be old-style classes or > derived from BaseException, not str',)) > > Does it mean in newer python I need to migrate all my Exception to non-string > based exception type? Correct. You can no longer do merely `raise "Some error message"`. You should instead raise an exception instance of the appropriate type; e.g. `raise ValueError("foo must be positive")`. It's advisable to read the NEWS / "What's New" documents for the intervening versions so you can learn what else has changed. > That's should be a lot of changes. :p To be fair, v1.5.2 is practically ancient at this point. It's over a decade old! And 2 *major* versions behind what's current. In a pinch, you could always write a script to mechanically change `raise "..."` to `raise StandardError("...")` [or some other fairly generic exception type]. Cheers, Chris -- http://mail.python.org/mailman/listinfo/python-list
RE: Python Migration Error: TypeError: exceptions must be old-style classes or derived from BaseException, not str
I see. Thanks for the tips. If I run out of time I shall consider only using 2.5. Regards, Wah Meng -Original Message- From: python-list-bounces+wahmeng=freescale@python.org [mailto:python-list-bounces+wahmeng=freescale@python.org] On Behalf Of Steven D'Aprano Sent: Monday, October 03, 2011 3:44 PM To: python-list@python.org Subject: Re: Python Migration Error: TypeError: exceptions must be old-style classes or derived from BaseException, not str On Mon, 03 Oct 2011 06:45:25 +, Wong Wah Meng-R32813 wrote: > Does it mean in newer python I need to migrate all my Exception to > non-string based exception type? That's should be a lot of changes. :p Yes. Python 1.5 is very old. It's over 11 years old. You might find it easier to first migrate to Python 2.5, where string exceptions are still legal and only generate a warning, and then migrate to 2.7. Good luck! -- Steven -- http://mail.python.org/mailman/listinfo/python-list -- http://mail.python.org/mailman/listinfo/python-list
Is exec() also not used in python 2.7.1 anymore?
In migrating my application from python 1.5.2 to 2.7.1, one of my modules breaks when I import it. Here is the line where it breaks. Can I have a quick check if this built-in function still supported in python 2.7.1 and if so, what ought to be changed here? Thanks in advance for replying. exec('def %s(self, *args, **kw): pass'%methodStrName) SyntaxError: unqualified exec is not allowed in function '_exposeMethods' it contains a nested function with free variables Regards, Wah Meng -- http://mail.python.org/mailman/listinfo/python-list
RE: Is exec() also not used in python 2.7.1 anymore?
Haha... yeah I reviewed the code, it is supposed to exposed some remote methods locally (RMI proxy usage). However, I am not sure why what it does is merely a pass. I commented out this code and haven't seen any negative implication. I will look into this again if I am convinced the next error I see is due to I commented out this code. Thanks! Regards, Wah Meng -Original Message- From: ch...@rebertia.com [mailto:ch...@rebertia.com] On Behalf Of Chris Rebert Sent: Tuesday, October 04, 2011 4:26 PM To: Wong Wah Meng-R32813 Cc: python-list@python.org Subject: Re: Is exec() also not used in python 2.7.1 anymore? On Tue, Oct 4, 2011 at 12:51 AM, Wong Wah Meng-R32813 wrote: > In migrating my application from python 1.5.2 to 2.7.1, one of my modules > breaks when I import it. Here is the line where it breaks. Can I have a > quick check if this built-in function still supported in python 2.7.1 Er, `exec` is a primitive statement, not a built-in function (so, the parens around it are superfluous), but yes, it's still present in 2.7. (Ironically, exec was changed to a function in Python 3.0.) > and if > so, what ought to be changed here? Thanks in advance for replying. > > exec('def %s(self, *args, **kw): pass'%methodStrName) Defining a do-nothing, dynamically-named function seems kinda strange in the first place; why are you doing this? Cheers, Chris -- http://rebertia.com -- http://mail.python.org/mailman/listinfo/python-list
ImportError: No module named _sha256
Hello there, In migrating my application from python 1.5.2 to 2.7.1, I encountered an issue modules which utilizes _sha256 cannot be loaded. This includes hashlib, random and tempfile. I think this should be related to the build of my python 64-bit on HP11.31 using HP-UX compiler. I have tried including the header files of openSSL and library of openSSL during the build however the binary generated still unable to load those modules. Can anyone advise? $ python Python 2.7.1 (r271:86832, Sep 30 2011, 17:07:25) [C] on hp-ux11 Type "help", "copyright", "credits" or "license" for more information. >>> import hashlib Traceback (most recent call last): File "", line 1, in File "/home/r32813/genesis/GEN_DEV_271/Enablers/Python/lib/python2.7/hashlib.py", line 136, in globals()[__func_name] = __get_hash(__func_name) File "/home/r32813/genesis/GEN_DEV_271/Enablers/Python/lib/python2.7/hashlib.py", line 74, in __get_builtin_constructor import _sha256 ImportError: No module named _sha256 >>> Regards, Wah Meng -- http://mail.python.org/mailman/listinfo/python-list
socket.getsockname is returning junk!!
Hello guys, I am migrating my application from python 1.5.2 to 2.7.1. One of the existing code breaks. The getsockname method from socket object somehow returns me with some number which I deem as junk, rather than the listening port as I would have expected in the older python. Has anyone seen the same thing or is it due to my python is built with some corrupted library or something? $ python Python 2.7.1 (r271:86832, Oct 5 2011, 18:34:15) [C] on hp-ux11 Type "help", "copyright", "credits" or "license" for more information. >>> import socket >>> sock = socket.socket( socket.AF_INET, socket.SOCK_STREAM ) >>> sock.setsockopt( socket.SOL_SOCKET, socket.SO_REUSEADDR, 1 ) >>> sock.setsockopt( socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1 ) >>> sock.setsockopt( socket.IPPROTO_TCP, 1, 1 ) >>> server_address=('zmy02hp3', 1) >>> sock.bind(server_address) >>> sock.getsockname() (0, '\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00') In python 1.5.2 >>> server_address=('zmy02aix04', 1) >>> sock.bind(server_address) >>> sock.getsockname() ('10.228.51.41', 1) >>> Regards, Wah Meng -- http://mail.python.org/mailman/listinfo/python-list
RE: socket.getsockname is returning junk!!
Thanks. Someone pointed out that this could be due to a corrupted build, which I revisited the process. I included -lxnet in the linking process of the build, and this problem is resolved. The -lxnet was stated in README file for HP-UX Itanium build, which I somehow dropped it out in the middle of the process and wasn't aware it was essential as excluding it cost me the junk I was seeing. Problem solved!! Thanks a lot for reverting. :) Regards, Wah Meng -Original Message- From: python-list-bounces+wahmeng=freescale@python.org [mailto:python-list-bounces+wahmeng=freescale@python.org] On Behalf Of Gabriel Genellina Sent: Friday, October 07, 2011 5:37 PM To: python-list@python.org Subject: Re: socket.getsockname is returning junk!! En Wed, 05 Oct 2011 08:56:08 -0300, Wong Wah Meng-R32813 escribió: > I am migrating my application from python 1.5.2 to 2.7.1. One of the > existing code breaks. The getsockname method from socket object somehow > returns me with some number which I deem as junk, rather than the > listening port as I would have expected in the older python. Has anyone > seen the same thing or is it due to my python is built with some > corrupted library or something? > > > $ python > Python 2.7.1 (r271:86832, Oct 5 2011, 18:34:15) [C] on hp-ux11 > Type "help", "copyright", "credits" or "license" for more information. >>>> import socket >>>> sock = socket.socket( socket.AF_INET, socket.SOCK_STREAM ) >>>> sock.setsockopt( socket.SOL_SOCKET, socket.SO_REUSEADDR, 1 ) >>>> sock.setsockopt( socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1 ) >>>> sock.setsockopt( socket.IPPROTO_TCP, 1, 1 ) >>>> server_address=('zmy02hp3', 1) >>>> sock.bind(server_address) >>>> sock.getsockname() > (0, '\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00') > > In python 1.5.2 >>>> server_address=('zmy02aix04', 1) >>>> sock.bind(server_address) >>>> sock.getsockname() > ('10.228.51.41', 1) I'd say it's a problem with the _socket module; did the unit tests flag anything when you built Python? On Windows, Python 2.7.1: >>> server_address=('lepton', 1) >>> sock.bind(server_address) >>> sock.getsockname() ('127.0.0.1', 1) -- Gabriel Genellina -- http://mail.python.org/mailman/listinfo/python-list -- http://mail.python.org/mailman/listinfo/python-list
import _tclinter error in python 2.7.1 Itanium build
Hello there, I am in the midst of converting my application code from python 1.5.2 to python 2.7.1. In the build of my python 2.7.1 on Itanium 64-bit HP11.3 platform, I noticed my Tkinter module was built and linked successfully, that I am able to import the module and use it. However, I just found out that my application that utilizes Tcl/Tk code, somehow wants to use _tclinter, instead of using _tkinter (In fact I have a Tkinter.py file) . The only comment I can see from the author is "Have Pic use Tclinter instead of Tkinter to allow Pic to start with a valid X Display". That comment was left at the time python 1.5.2 and tcl/tk 8.1 (maybe) was used and I am not sure if the same issue is applicable to the current version of python and tcl/tk. However, the question I want to ask is, I build python when tcl/tk files are both available, why only tk is detected and built-in with python, not tcl? $ python Python 2.7.1 (r271:86832, Oct 6 2011, 11:10:10) [C] on hp-ux11 Type "help", "copyright", "credits" or "license" for more information. >>> import Tkinter >>> import Tclinter Traceback (most recent call last): File "", line 1, in File "Tclinter.py", line 5, in import _tclinter # If this fails your Python is not configured for Tcl ImportError: No module named _tclinter >>> import _tclinter Traceback (most recent call last): File "", line 1, in ImportError: No module named _tclinter >>> import _tkinter >>> Regards, Wah Meng -- http://mail.python.org/mailman/listinfo/python-list
Timeout when calling COM objects on Windows
Hello there, I am converting my VB ActiveX application written sometime back in year 2000 with python 1.5.2 to run in python 2.7.1. My application is using RMI architecture and I am using a pythonOleRmi.py parser to exchange data/objects between the python and the VB exe. I have no issue when my VB EXE is not running as a COM server while making python API calls where my application server is written purely in python and runs on UNIX. However, when my VB EXE is running as a COM server, this code seems hangs when I make the python API same call to the application server. Is there something that I need to change or configure in order to run this successfully? Or to make some security setting on my Windows? (My VB EXE is run on Windows 7 now, will try out if the same issue is encountered on XP next week). Is the issue resided in the calling to the local daemon process (10.228.70.137:26000), or it is some security setting depicted in the policy.py file? Collecting Python Trace Output... Proxy called with: MatlMgr, getCompatibleFTCSVersions(), (), {} Dec 23 18:41:21 OleRmiClient Timeout of 300 seconds occurred on the invocati on of ('getAppAddress', (u'MatlMgr',), {}) to ('10.228.70.137', 26000) pythoncom error: Python error invoking COM method. Traceback (most recent call last): File "C:\genesis\Enablers\Python\lib\site-packages\win32com\server\policy.py", line 277, in _Invoke_ return self._invoke_(dispid, lcid, wFlags, args) File "C:\genesis\Enablers\Python\lib\site-packages\win32com\server\policy.py", line 282, in _invoke_ return S_OK, -1, self._invokeex_(dispid, lcid, wFlags, args, None, None) File "C:\genesis\Enablers\Python\lib\site-packages\win32com\server\policy.py", line 585, in _invokeex_ return func(*args) File "C:\genesis\Product\Lib\PythonOleRmi.py", line 240, in Proxy proxy = self._getProxyObj(pyserverString) File "C:\genesis\Product\Lib\PythonOleRmi.py", line 223, in _getProxyObj None, self._logWriter, rem_admin_addr = remAddr ) File "C:\genesis\Product\Lib\EComponent.py", line 710, in __init__ addr = self._getAppProxyAddress() File "C:\genesis\Product\Lib\EComponent.py", line 742, in _getAppProxyAddress addr = remAdmin.getAppAddress(self.server_name) File "C:\genesis\Product\Lib\EComponent.py", line 611, in __call__ self._method, args, kw ) File "C:\genesis\Product\Lib\RMI.py", line 1779, in _genericInvocation reply = self._requestReply( replyBit, (method_name, args, kw) ) File "C:\genesis\Product\Lib\RMI.py", line 1585, in _requestReply reply = self._receive() File "C:\genesis\Product\Lib\RMI.py", line 1677, in _receive raise ServerReplyTimeout( self.reply_timeout) ServerReplyTimeout: 300 Regards, Wah Meng -- http://mail.python.org/mailman/listinfo/python-list
Set x to to None and del x doesn't release memory in python 2.7.1 (HPUX 11.23, ia64)
Hello there, I am using python 2.7.1 built on HP-11.23 a Itanium 64 bit box. I discovered following behavior whereby the python process doesn't seem to release memory utilized even after a variable is set to None, and "deleted". I use glance tool to monitor the memory utilized by this process. Obviously after the for loop is executed, the memory used by this process has hiked to a few MB. However, after "del" is executed to both I and str variables, the memory of that process still stays at where it was. Any idea why? >>> for i in range(10L): ... str=str+"%s"%(i,) ... >>> i=None >>> str=None >>> del i >>> del str -- http://mail.python.org/mailman/listinfo/python-list
RE: Set x to to None and del x doesn't release memory in python 2.7.1 (HPUX 11.23, ia64)
Apologies as after I have left the group for a while I have forgotten how not to post a question on top of another question. Very sorry and appreciate your replies. I tried explicitly calling gc.collect() and didn't manage to see the memory footprint reduced. I probably haven't left the process idle long enough to see the internal garbage collection takes place but I will leave it idle for more than 8 hours and check again. Thanks! -Original Message- From: Python-list [mailto:python-list-bounces+wahmeng=freescale@python.org] On Behalf Of Bryan Devaney Sent: Wednesday, March 06, 2013 6:25 PM To: python-list@python.org Cc: python-list@python.org Subject: Re: Set x to to None and del x doesn't release memory in python 2.7.1 (HPUX 11.23, ia64) On Wednesday, March 6, 2013 10:11:12 AM UTC, Wong Wah Meng-R32813 wrote: > Hello there, > > > > I am using python 2.7.1 built on HP-11.23 a Itanium 64 bit box. > > > > I discovered following behavior whereby the python process doesn't seem to > release memory utilized even after a variable is set to None, and "deleted". > I use glance tool to monitor the memory utilized by this process. Obviously > after the for loop is executed, the memory used by this process has hiked to > a few MB. However, after "del" is executed to both I and str variables, the > memory of that process still stays at where it was. > > > > Any idea why? > > > > >>> for i in range(10L): > > ... str=str+"%s"%(i,) > > ... > > >>> i=None > > >>> str=None > > >>> del i > > >>> del str Hi, I'm new here so I'm making mistakes too but I know they don't like it when you ask your question in someone else's question. that being said, to answer your question: Python uses a 'garbage collector'. When you delete something, all references are removed from the object in memory, the memory itself will not be freed until the next time the garbage collector runs. When that happens, all objects without references in memory are removed and the memory freed. If you wait a while you should see that memory free itself. -- http://mail.python.org/mailman/listinfo/python-list -- http://mail.python.org/mailman/listinfo/python-list
RE: Set x to to None and del x doesn't release memory in python 2.7.1 (HPUX 11.23, ia64)
Thanks for youre reply. I built python 2.7.1 binary myself on the HP box and I wasn't aware there is any configuration or setup that I need to modify in order to activate or engage the garbage collection (or even setting the memory size used). Probably you are right it leaves it to the OS itself (in this case HP-UX) to clean it up as after python removes the reference to the address of the variables the OS still thinks the python process should still owns it until the process exits. Regards, Wah Meng -Original Message- From: Python-list [mailto:python-list-bounces+wahmeng=freescale@python.org] On Behalf Of Terry Reedy Sent: Wednesday, March 06, 2013 7:00 PM To: python-list@python.org Subject: Re: Set x to to None and del x doesn't release memory in python 2.7.1 (HPUX 11.23, ia64) On 3/6/2013 5:11 AM, Wong Wah Meng-R32813 wrote: > Hello there, > > I am using python 2.7.1 built on HP-11.23 a Itanium 64 bit box. > > I discovered following behavior whereby the python process doesn't > seem to release memory utilized even after a variable is set to None, > and "deleted". I use glance tool to monitor the memory utilized by > this process. Obviously after the for loop is executed, the memory > used by this process has hiked to a few MB. However, after "del" is > executed to both I and str variables, the memory of that process still > stays at where it was. Whether memory freed by deleting an object is returned to and taken by the OS depends on the OS and other factors like like the size and layout of the freed memory, probably the history of memory use, and for CPython, the C compiler's malloc/free implementation. At various times, the Python memory handlers have been rewritten to encourage/facilitate memory return, but Python cannot control the process. > for i in range(10L): > str=str+"%s"%(i,) > i=None; str=None # not necessary > del i; del str Reusing built-in names for unrelated purposes is generally a bad idea, although the final deletion does restore access to the builtin. -- Terry Jan Reedy -- http://mail.python.org/mailman/listinfo/python-list -- http://mail.python.org/mailman/listinfo/python-list
RE: Set x to to None and del x doesn't release memory in python 2.7.1 (HPUX 11.23, ia64)
Python does not guarantee to return memory to the operating system. Whether it does or not depends on the OS, but as a general rule, you should expect that it will not. for i in range(10L): > ... str=str+"%s"%(i,) You should never build large strings in that way. It risks being horribly, horribly slow on some combinations of OS, Python implementation and version. Instead, you should do this: items = ["%s" % i for i in range(10)] s = ''.join(items) [] The example is written for illustration purpose. Thanks for pointing out a better way of achieving the same result. Yes it seems so that the OS thinks the piece allocated to Python should not be taken back unless the process dies. :( -- http://mail.python.org/mailman/listinfo/python-list
RE: Set x to to None and del x doesn't release memory in python 2.7.1 (HPUX 11.23, ia64)
The problem is my server hits memory usage threshold, and starts giving me errors like Oracle unable to spawn off new session stating Out of Memory error and what not. I won't be bothered much if I have the luxury of available memory for other processes to use. If only if the UNIX understand my concerns and release the allocation when I issue gc.collect() or the gc.collect() takes place. :) On Thu, Mar 7, 2013 at 5:33 PM, Wong Wah Meng-R32813 wrote: > [] The example is written for illustration purpose. Thanks for > pointing out a better way of achieving the same result. Yes it seems > so that the OS thinks the piece allocated to Python should not be > taken back unless the process dies. :( Don't be too bothered by that. That memory will be reused by Python for subsequent allocations. -- http://mail.python.org/mailman/listinfo/python-list
RE: Set x to to None and del x doesn't release memory in python 2.7.1 (HPUX 11.23, ia64)
If the memory usage is continually growing, you have something else that is a problem -- something is holding onto objects. Even if Python is not returning memory to the OS, it should be reusing the memory it has if objects are being freed. -- [] Yes I have verified my python application is reusing the memory (just that it doesn't reduce once it has grown) and my python process doesn't have any issue to run even though it is seen taking up more than 2G in footprint. My problem is capacity planning on the server whereby since my python process doesn't release memory back to the OS, the OS wasn't able to allocate memory when a new process is spawn off. -- http://mail.python.org/mailman/listinfo/python-list