Sunday, January 13, 2008

Problem installing pyParallel module in python

When they said experimental, I didn't expect this much. I mean; a bug even in the installer??? Sheesh! But thanks to the simplicity of python, I could understand the bug and find a solution. If it was for C++ or Java, I would have simply dropped my whole project! ;)

Now that I've found a solution and I couldn't find it listed in the first three pages of Google search results, I want to share it...

My problem was that when I tried to run and install the pyParallel module:
python setup.py install

I got something like:
running install
running build
running build_py
Traceback (most recent call last):
File "setup.py", line 19, in
package_data = data_files
File "/usr/lib64/python2.5/distutils/core.py", line 151, in setup
dist.run_commands()
.
.
.
.
file[plen:] for file in self.find_data_files(package, src_dir)
File "/usr/lib64/python2.5/distutils/command/build_py.py", line 128, in find_data_files
globs = (self.package_data.get('', [])
AttributeError: 'NoneType' object has no attribute 'get'


Even if looks like we're in deep sh**, we're actually not...
Its just a simple logical error in the way the function is called. In the setup.py,
the function setup should have been called with an argument, "package_data = a dictionary value pair of what & which dependency file is to be installed" if the os is 'nt' & you don't need to give that package_data argument if the os is something else(perhaps there is a default value in the function definition). But our setup.py passes a "package_data = None". So all we have to do is to call the setup function properly without passing a "package_data = None" argument.
Here's what I did to the setup.py:

#!/usr/bin/env python
from distutils.core import setup

import os
args={"name" : "pyparallel",
"description":"Python Parallel Port Extension",
"version":"0.2", "author":"Chris Liechti",
"author_email":"cliechti@gmx.net",
"url":"http://pyserial.sourceforge.net/",
"packages":['parallel'],
"license":"Python",
"long_description":"Python Parallel Port Extension for Win32, Linux, BSD",
}

if os.name == 'nt': args["package_data"] = {'parallel': ['simpleio.dll']}

setup(**args)

8 comments:

E said...

Thanks! That really helped.
What I have know (in my kubuntu) is this:

>>> import parallel
>>> p=parallel.Parallel()
...
File "parallel/parallelppdev.py", line 188, in __init__
self.PPCLAIM()
File "parallel/parallelppdev.py", line 215, in PPCLAIM
fcntl.ioctl(self._fd, PPCLAIM)
IOError: [Errno 6] No such device or address
"
Maybe you have any idea how to fix this?
Thanks!

E said...

OK got it to work:
I had both "ppdev" and "lp" modules loaded, so what I did is:
> sudo rmmod lp
> sudo python

and it works!

fayaz said...

Yeah... I should have mentioned that too... But now as you have done the job for me :) , I need only explain the alternatives...

See, you get the error because of ownership problems... So there are many ways to solve it (although some of them don't look good & some of them don't just work properly)

Like changing the ownership, including yourself to the respective group or being the owner of /dev/parport or /dev/lp...

dt said...

this worked perfectly. Thanks a bunch!

Unknown said...

can somone explain to me how to change the ownership of /dev/parport?

fayaz said...

@Josh, you can change the ownership of any file using the command "sudo chown user:group filename"

sivananda said...

I tried the following and it worked for me
sudo rmmod lp
sudo gpasswd --add [user] lp
sudo chown user:lp /dev/parport0
sudo chmod 666 /dev/parport0

Lewis said...

Thanks you fixed the very same problem I ran into.