DistutilsPlatformError
I'm trying to build an extension for Python 3. I'm using the example code in the book "Python Essential Reference", 4ed. I have it working for Python 2. But when I try to build it for Python 3 I get the following error: distutils.errors.DistutilsPlatformError: Microsoft Visual C++ 10.0 is required ( Unable to find vcvarsall.bat). How can this be fixed? I'm using Python 3.4.3, obtained from Anaconda, on Win XP Thanks in advance garyr - # setup.py from setuptools import setup, Extension setup(name="example", version = "1.0", ext_modules = [ Extension("_example", ["pyexample.c", "example.c"]) ] ) -- https://mail.python.org/mailman/listinfo/python-list
distutils error ?
I tried building the spammodule.c example described in the documentation section Extending Python with C or C++. As shown the code compiles OK but generates a link error: LINK : error LNK2001: unresolved external symbol init_spam build\temp.win32-2.7\Release\_spam.lib : fatal error LNK1120: 1 unresolved externals I tried changing the name of the initialization function spam_system to init_spam and removed the static declaration. This compiled and linked without errors but generated a system error when _spam was imported. The same error occurs with Python 2.6 and the current compiler. The code and the setup.py file are shown below. setup.py: - from setuptools import setup, Extension setup(name='spam', version='0.1', description='test module', ext_modules=[Extension('_spam', ['spammodule.c'], include_dirs=[C:\Documents and Settings\Owner\Miniconda\include], )], ) sammodule.c -- #include python.h static PyObject *SpamError; static PyObject * spam_system(PyObject *self, PyObject *args) { const char *command; int sts; if (!PyArg_ParseTuple(args, s, command)) return NULL; sts = system(command); if (sts 0) { PyErr_SetString(SpamError, System command failed); return NULL; } return PyLong_FromLong(sts); } static PyMethodDef SpamMethods[] = { {system, spam_system, METH_VARARGS, Execute a shell command.}, {NULL, NULL, 0, NULL}/* Sentinel */ }; PyMODINIT_FUNC initspam(void) { PyObject *m; m = Py_InitModule(spam, SpamMethods); if (m == NULL) return; SpamError = PyErr_NewException(spam.error, NULL, NULL); Py_INCREF(SpamError); PyModule_AddObject(m, error, SpamError); } -- https://mail.python.org/mailman/listinfo/python-list
Extension build link error
I'm trying to build an extension module and was having problems so I decided to try something simpler. Article 16.5, Coding the Methods of a Python Class in C in the first edition of the Python Cookbook looked about right. I generated the code and a setup.py file (shown below). When I run python setup.py build_ext --inplace I get the following errors: LINK : error LNK2001: unresolved external symbol init_Foo build\temp.win32-2.7\Release\_Foo.lib : fatal error LNK1120: 1 unresolved externals If I change the name of the initialization function from Foo_init (as in the book) to init_Foo the build succeeds but import _Foo fails: import _Foo SystemError: dynamic module not initialized properly This is the problem I was having with the extension module I was trying to write. What can I do to correct this? I'm using Python 2.7 on Win XP. == # File: setup.py from setuptools import setup, Extension setup(name='Foo', version='0.1', ext_modules=[Extension('_Foo', ['Foo.c'], include_dirs=['C:\Program Files\Common Files\Microsoft\Visual C++ for Python\9.0\VC\include', 'C:\Miniconda\include'], )], ) = # File: Foo.c #include Python.h PyObject* init_Foo(PyObject *self, PyObject *args){ printf(Foo.__init__ called\n); Py_INCREF(Py_None); return Py_None; } static PyObject* Foo_doSomething(PyObject *self, PyObject *args){ printf(Foo.doSomething called\n); Py_INCREF(Py_None); return Py_None; } static PyMethodDef FooMethods[] = { {__init__,init_Foo, METH_VARARGS, doc_string}, {doSomething, Foo_doSomething, METH_VARARGS, doc string}, {0, 0}, }; static PyMethodDef ModuleMethods[] = {{0,0}}; void initFoo() { PyMethodDef *def; PyObject *module = Py_InitModule(Foo, ModuleMethods); PyObject *moduleDict = PyModule_GetDict(module); PyObject *classDict = PyDict_New(); PyObject *className = PyString_FromString(Foo); PyObject *fooClass = PyClass_New(NULL, classDict, className); PyDict_SetItemString(moduleDict, Foo, fooClass); Py_DECREF(classDict); Py_DECREF(className); Py_DECREF(fooClass); for (def = FooMethods; def-ml_name != NULL; def++) { PyObject *func = PyCFunction_New(def, NULL); PyObject *method = PyMethod_New(func, NULL, fooClass); PyDict_SetItemString(classDict, def-ml_name, method); Py_DECREF(func); Py_DECREF(method); } } -- https://mail.python.org/mailman/listinfo/python-list
Re: Basic Info
ch.tanvee...@gmail.com wrote in message news:178f0eac-1760-40b3-9c10-c2d007588...@googlegroups.com... Hi friends, M Tanveer, and wanna start to learn python language, i've installed python on my Windows (OS) and set path to it, Now please Guide me which editor is best to use and what instructions should be followed . Best Regards: Tanveeer Ahmad Thanks SciTe is an excellent editor for Python C, C++, etc. http://www.scintilla.org/SciTE.html -- https://mail.python.org/mailman/listinfo/python-list
Re: Building an extension module with SWIG
*snip* Compile it (cythonize -b foo.pyx) and you'll get an extension module that executes faster than what SWIG would give you and keeps everything in one file to improve readability. Stefan [1] http://cython.org/ Thanks for your reply. My interest is not in computing the gcd but to learn how build an extension module. I have some much more complicated C code I wish to use. -- https://mail.python.org/mailman/listinfo/python-list
Building an extension module with SWIG
I'm trying to create an extension module using SWIG. I've succeeded in generating a pyd file but when I import the module I get the error message: SystemError: dynamic module not initialized properly. I added an initfoo() function but that didn't solve the problem. Below are the various files, a slightly modified version of a SWIG exmaple. I'm using Python 2.7 What am I missing? //foo.c: #include foo.h double Foo; void initfoo() { Foo = 3.0; } int gcd(int x, int y) { int g; g = y; while (x 0) { g = x; x = y % x; y = g; } return g; } #foo.h: extern void initfoo(); extern double Foo; extern int gcd(int x, int y); #foo.i: %module example %inline %{ extern intgcd(int x, int y); extern double Foo; %} #setup.py from setuptools import setup, Extension setup(name='foo', version='0.1', ext_modules=[Extension('foo', ['foo.c', 'foo.i'], include_dirs=['.'], depends=['foo.h', 'foo.i'], swig_opts=['-modern', '-I../include'], )], ) -- https://mail.python.org/mailman/listinfo/python-list
Re: Building an extension module with SWIG
garyr ga...@fidalgo.net wrote in message news:mkco9p$gf8$1...@speranza.aioe.org... I'm trying to create an extension module using SWIG. I've succeeded in generating a pyd file but when I import the module I get the error message: SystemError: dynamic module not initialized properly. I added an initfoo() function but that didn't solve the problem. Below are the various files, a slightly modified version of a SWIG exmaple. I'm using Python 2.7 What am I missing? //foo.c: #include foo.h double Foo; void initfoo() { Foo = 3.0; } int gcd(int x, int y) { int g; g = y; while (x 0) { g = x; x = y % x; y = g; } return g; } #foo.h: extern void initfoo(); extern double Foo; extern int gcd(int x, int y); #foo.i: %module example %inline %{ extern intgcd(int x, int y); extern double Foo; %} #setup.py from setuptools import setup, Extension setup(name='foo', version='0.1', ext_modules=[Extension('foo', ['foo.c', 'foo.i'], include_dirs=['.'], depends=['foo.h', 'foo.i'], swig_opts=['-modern', '-I../include'], )], ) It's working! The first character of the name of the extension must be an underscore; e.g., ext_modules=[Extension('_foo', ['foo.c', 'foo.i'], and the initfoo() function is not needed. Thanks to all that replied to my post. -- https://mail.python.org/mailman/listinfo/python-list
Re: Building an extension module with SWIG
garyr ga...@fidalgo.net wrote in message news:mkd7nk$isi$1...@speranza.aioe.org... *snip* Compile it (cythonize -b foo.pyx) and you'll get an extension module that executes faster than what SWIG would give you and keeps everything in one file to improve readability. Stefan [1] http://cython.org/ Thanks for your reply. My interest is not in computing the gcd but to learn how build an extension module. I have some much more complicated C code I wish to use. Thanks for your reply. I'm using the compiler that came with Anaconda Python 2.7. I too used SWIG a bunch of years ago but it has changed a lot since then; e.g., it is now included in the Python distribution. -- https://mail.python.org/mailman/listinfo/python-list
cl.exe missing
I posted this on the Anaconda NG but haven't gotten an answer. I recently installed Python 2.7 using Miniconda. I'm now trying to build a Python extension module. My setup.py file is: from distutils.core import setup, Extension module1 = Extension('pyssound', sources=['ssound.cpp', 'pyssound.cpp']) setup(name=pyssound, version=1.0, ext_modules = [module1]) Initially I got the vcvarsall.bat missing error and I found the fix for that: set MSSDK=1 set DISTUTILS_USE_SDK=1 Now when I run setup I get: python setup.py build running build running build_ext building 'pyssound' extension cl.exe /c /nologo /Ox /MD /W3 /GS- /DNDEBUG -IC:\Documents and Settings\Owner\M iniconda\include -IC:\Documents and Settings\Owner\Miniconda\PC /Tpssound.cpp /Fobuild\temp.win32-2.7\Release\ssound.obj error: command 'cl.exe' failed: No such file or directory cl.exe is the Visual Studio VS2008 compiler which is the one used to compile Python 2.7. A search for VS2008 turns up this site: http://www.microsoft.com/en-us/download/details.aspx?id=10986 which mentions vs2010, 2012 and 2013 but not 2008. Where do I find VS2008? -- https://mail.python.org/mailman/listinfo/python-list
Re: cl.exe missing
Where do I find VS2008? Try this: https://www.microsoft.com/en-gb/download/details.aspx?id=44266 TJG Yes, that's it. Many thanks. -- https://mail.python.org/mailman/listinfo/python-list
SciPy for Python 2.6?
Is there a version for SciPy/numpy available for Python 2.6? I could only find a version for 2.7 on the SciPy site. A search on the Scipy mailing list archive did not turn up anything. The link to the Scipy-user list signup appeared to be broken. -- http://mail.python.org/mailman/listinfo/python-list
Re: Deleting a file?
Jerry, There was an error during the install but only required a minor change to an __init__.py file to correct. Works great. Just what I was looking for. Many thanks! Gary Jerry Hill malaclyp...@gmail.com wrote in message news:mailman.1654.1305601607.9059.python-l...@python.org... On Mon, May 16, 2011 at 5:23 PM, garyr ga...@fidalgo.net wrote: A file can be deleted by opening it with mode os.O_TEMPORARY and then closing it. How can a file be moved to the Recycle Bin, a la Windows? I see a send2trash module (http://hg.hardcoded.net/send2trash and http://www.hardcoded.net/articles/send-files-to-trash-on-all-platforms.htm) The source code looks pretty straightforward, but I don't think there's anything in the standard library that does that. -- Jerry -- http://mail.python.org/mailman/listinfo/python-list
Deleting a file?
A file can be deleted by opening it with mode os.O_TEMPORARY and then closing it. How can a file be moved to the Recycle Bin, a la Windows? -- http://mail.python.org/mailman/listinfo/python-list
tkFileDialog Question
tkFileDialog.askdirectory() allows the selection of a directory. In my code it displays a line of text at the top of the frame (Please choose a directory, then select OK). A little below that the current path (C:\Documents and Settings\Owner\My Documents\Python\...) is displayed as a string and immediately below that in a small frame the basename of the path is displayed. In my case the string showing the path is too long and is displayed on two lines, the bottom part of which is obscured by the frame displaying the basename. The title text referred to above can be changed by means of the title option in the function call but there doesn't appear to be an option for the path. Is there some other way the display of the path or the frame displaying the basename could be eliminated or moved slightly? -- http://mail.python.org/mailman/listinfo/python-list
Python 2.6 bsddb
I recently installed ActivePython 2.6.6 and my programs that use anydbm or shelve generate import errors because bsddb is missing. I installed bsddb3 (bsddb3-5.0.0.win32-py2.6.exe) but that didn't change anything. What more do I need to do? -- http://mail.python.org/mailman/listinfo/python-list
Tkinter 3000 WCK Install Problem
I'm trying to install WCK. I downloaded and installed the Windows executable for my Python version. It appeared to run OK. I then downloaded the demo files but find that none run due to error: ImportError: No module named _tk3draw. I'm using ActivePython 2.3.5 on Windows XP Home. What can I do to fix this problem? -- http://mail.python.org/mailman/listinfo/python-list
py2exe, pyparallel
I'm using py2exe to create a standalone program that uses pyparallel. When I run the created program an error occurs and a message directs me to the log file which contains: Traceback (most recent call last): File fg.py, line 30, in ? import dds2 File dds2.pyc, line 24, in ? WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR File parallel\__init__.pyc, line 13, in ? File parallel\parallelwin32.pyc, line 59, in ? File ctypes\__init__.pyc, line 407, in __getattr__ File ctypes\__init__.pyc, line 319, in __init__ WindowsError: [Errno 1157] One of the library files needed to run this application cannot be found My setup.py is: from distutils.core import setup import py2exe setup(windows = [fg.py]) Line 59 in parallelwin32.py is: _pyparallel = ctypes.windll.simpleio. I'm using PythonWin 2.3.2 on Win98SE. I have ctypes 0.9.6, py2exe 0.6.3 and pyparallel 0.2 installed. I posted a similar message to the py2exe mailing list but apparently that list is inactive. Any suggestions appreciated. Thanks, Gary Richardson -- http://mail.python.org/mailman/listinfo/python-list
Re: py2exe, pyparallel
Chris Mellon wrote: On 13 Nov 2005 10:03:52 -0800, [EMAIL PROTECTED] [EMAIL PROTECTED] wrote: I'm using py2exe to create a standalone program that uses pyparallel. When I run the created program an error occurs and a message directs me to the log file which contains: Traceback (most recent call last): File fg.py, line 30, in ? import dds2 File dds2.pyc, line 24, in ? WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR File parallel\__init__.pyc, line 13, in ? File parallel\parallelwin32.pyc, line 59, in ? File ctypes\__init__.pyc, line 407, in __getattr__ File ctypes\__init__.pyc, line 319, in __init__ WindowsError: [Errno 1157] One of the library files needed to run this application cannot be found My setup.py is: from distutils.core import setup import py2exe setup(windows = [fg.py]) Line 59 in parallelwin32.py is: _pyparallel = ctypes.windll.simpleio. I'm using PythonWin 2.3.2 on Win98SE. I have ctypes 0.9.6, py2exe 0.6.3 and pyparallel 0.2 installed. I posted a similar message to the py2exe mailing list but apparently that list is inactive. Any suggestions appreciated. Thanks, Gary Richardson This *looks* like all that's happening is that ctypes is unable to load the dll simpleio.dll , which is not a standard windows library and therefore needs to be somewhere LoadLibrary can find it. -- http://mail.python.org/mailman/listinfo/python-list Thanks for you reply. Yes, copying simpleio.dll to my dist directory corrected the problem. The program now runs but I get an error message when it terminates that directs me to the log file where I find the message: C:\MY DOCUMENTS\PYTHON\DDS\DIST\library.zip\dds2.py:96: FutureWarning: xy losing bits or changing sign will return a long in Python 2.4 and up I added the statement from __future__ import division to dds2.py and no longer see that message when I run the program from Python. So why should I see it when the standalone program runs? -- http://mail.python.org/mailman/listinfo/python-list
Re: pyparallel and MAKE controller board for CRYDOM AC/DC switches
Richard Siderits wrote: Greetings. I am trying to write a small application for controlling CRYDOM AC and DC switches from the parallel port using pyparallel. The project is described in the latest issue of MAKE magazine Vol.3 pg 86. All of the examples are in C, VB, Linux, Unix but not a thing in Python. Seems like a perfect application for a Python program or even a simple windowed app. Problem is I'm stuck. How, for example, would I format the setData() to turn off data PIN 3? If I knew that then.. Life, the Universe and Everything would be better. Progress so far: import parallel, time, ctypes p=parallel.Parallel(1) p.setData(0) p.setDataStrobe(0) print Boy are you stuck! THANKS for any help!! Here is some code that may do what you want: from parallel import * class P: def __init__(self, port): self.dataReg = 0 self.p = Parallel(port) def setData(self, value): self.dataReg = value self.p.setData(value) def setDataBit(self, bit, value): assert 0 = bit = 7 assert 0 = value = 1 mask = 1 bit self.dataReg = (self.dataReg ~mask) if value: self.dataReg += mask self.p.setData(self.dataReg) if __name__ == '__main__': import msvcrt, time bit = 1 pyp = P(LPT1) pyp.setData(0xff) # set all bits high print 'all bits high' while not msvcrt.kbhit(): time.sleep(0.1) ch = msvcrt.getch() while 1: pyp.setDataBit(bit, 0) # set bit bit low print 'bit %d low' % (bit, ) while not msvcrt.kbhit(): time.sleep(0.1) ch = msvcrt.getch() if ord(ch) == 27: # esc break pyp.setDataBit(bit, 1) # now high print 'bit %d high' % (bit, ) while not msvcrt.kbhit(): time.sleep(0.1) ch = msvcrt.getch() if ord(ch) == 27: # esc break -- http://mail.python.org/mailman/listinfo/python-list
Re: Mouseclick
Terje Johan Abrahamsen wrote: Hello. I have been trying desperately for a while to make Python push the left mousebutton. I have been able to let Python push a button in a box: def click(hwnd): win32gui.SendMessage(hwnd, win32con.WM_LBUTTONDOWN, 0, 0) win32gui.SendMessage(hwnd, win32con.WM_LBUTTONUP, 0, 0) optDialog = findTopWindow(wantedText=Options) def findAButtonCalledOK(hwnd, windowText, windowClass): return windowClass == Button and windowText == OK okButton = findControl(optDialog, findAButtonCalledOK) click(okButton) As described here, http://tinyurl.com/cwjls. But, that is not what I am looking for. I would like to specify some coordinates such as windll.user32.SetCursorPos(450, 370) and thereafter click the left mousebutton at that place. I know that the sollution lies somewhere with Microsoft (http://www.6URL.com/FED), but cannot understand how to make Python click the button regardless of how much I try. Thanks in advance. Another, perhaps not so cool, way of doing this is to just invoke the mouse handler functions directly. e.g.: class Event: def __init__(self, x, y): self.x = x self.y = y class Whatever: . . def mouseClick(self, event): self.mouseDown(event)# link to ButtonPress handler self.mouseUp(event) # link to ButtonRelease handler ... event.x, event.y = 123, 456 self.mouseClick(event) -- http://mail.python.org/mailman/listinfo/python-list
Re: tkMessageBox dialog help
Nathan wrote: Hi, I've been testing the standard dialog boxes in tkMessageBox under IDLE. If I type for example, tkMessageBox.askyesno('test', 'test'), the dialog box comes up fine but another window also appears. I'm guessing this is the parent window of the message box. If I click on either of the yes/no buttons, i get a True/False on the std out and the dialog box closes but the parent window remains and seems to hang. This is on WinXP by the way. Is this normal behaviour? How do I get the dialog box appearing without the parent window or is this not possible? Thanks, Nathan. See the post to this NG by Jeff Epler on Apr 12, Tkinter withdraw and askstring problem I think you can find the answer to your question there. -- http://mail.python.org/mailman/listinfo/python-list