[Tutor] hard time importing a module

Oscar Benjamin oscar.j.benjamin at gmail.com
Fri Apr 19 17:12:36 CEST 2013


On 19 April 2013 15:49, Frank Schiro <fahraynk at gmail.com> wrote:
> hi I have a question about modules ...
>
> Im trying to use a 3rd party module called pywinatuo. It said I had to
> install 2 other modules. 1 was called sendkeys.py, the other was ctypes.
> Ctypes was included in the python library I had, but sendkeys was not.
>
> After I found SendKeys, I put it in a directory I found in sys.path, and
> then type import SendKeys. I got an error because sendkeys was trying to
> import from another file called _sendkeys. After searching I found
> _sendkeys, but it is .c

Did these files also come with a file called setup.py?

Normally, a Python module is not installed by manually copying the
files to the appropriate places but by running 'python setup.py
install' in the terminal. This will compile any C code and copy files
to the appropriate places. Note that you will need to have separately
installed a C compiler to be able to compile C code.


>
> I know that you can somehow extend python with c from reading this article :
> http://docs.python.org/2/extending/extending.html

Try reading this one instead:
http://docs.python.org/2/install/index.html

>
> But... how do I get the interpreter to recognize the _sendkeys.c file when
> sendkeys.py trys to import it ? I get errors right away since c uses * to
> comment so python doesnt recognize it and errors on all of the comments from
> _sendkeys.c

Yeah, that won't work. C code needs to be compiled by a C compiler, not Python.

>
> Basically how do I correctly import this module that doesnt have a setup.py
> ?

Oh okay, no setup.py. Where did you get this from? What does it have?
Is there a Makefile or something?


Oscar


More information about the Tutor mailing list