Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Install Python Modules

I've always taught myself how to write programs, with very little formal education, so I always feel like I'm missing some things that formal education may offer. In this case, I want to install a new module for Python. It's the pyhk hotkey module. I'm helping a coworker work with hot keys. The problem I have with modules is, they completely baffle me on how to install on my computer for use.

Rarely do i get an executable, which is easy, but sometimes I think you have to copy and paste .dll's or run command prompt and import .dll's but I never really know how to do this and I just find it's strange that there is very little documentation out there to help with with this....therefore I believe i may be missing something. Can anyone help me out and explain how to install python modules?

Thanks, Mike

like image 451
Mike Avatar asked Jan 14 '23 01:01

Mike


2 Answers

Let setup tools worry about directories and python path for you. Avoid copying things by hand, doing things the proper way in python for this is actually simpler than improvising and copying things by hand.

First, what about improving this useful module by using setuptools? The author helped you with useful code, now you can also contribute back by helping him with packaging!

Create a better directory structure, put the single source file inside a module to minimize the chance of namespace conflicts and create the setup.py

All you're going to need can be found here: http://pythonhosted.org/an_example_pypi_project/setuptools.html

An here follows an example:

import os
from setuptools import setup


setup(
    name = "pyhk",
    version = "0.0.4",
    author = "Someone",
    author_email = "[email protected]",
    description = ("Some desc"),
    license = "Some license",
    packages=['pyhk'],
    classifiers=[
        "Development Status :: 3 - Alpha",
        "Topic :: Utilities",
    ],
)
like image 195
Marcos Eliziário Santos Avatar answered Jan 17 '23 14:01

Marcos Eliziário Santos


Update

First install pywin32 and pyHook...


  1. Extract the contents of the archive
  2. Copy the file pyhk.py to your python Lib directory.

In Windows, the Lib directory will be

<PATH TO PYTHON>\Lib

Example:

c:\python\Lib

In Linux, it will normally be at

/usr/lib/python2.7/
like image 38
ATOzTOA Avatar answered Jan 17 '23 14:01

ATOzTOA