python3: cannot load pylirc

Asked by Alexander Bubnov

Hello! pylirc cannot be found during import in python3 scripts. But for python2 it works. I use pip3 to install pylirc because my Linux distribution has no package pylirc for python3. But it has for python2. Is that a bug somewhere in python3? Do you think there is a workaround?
> python3 -c 'import pylirc'
Traceback (most recent call last):
  File "<string>", line 1, in <module>
ImportError: No module named 'pylirc'

> lsb_release -a
No LSB modules are available.
Distributor ID: LinuxMint
Description: Linux Mint 17.3 Rosa
Release: 17.3
Codename: rosa

> sudo pip3 install pylirc2
Downloading/unpacking pylirc2
  Downloading pylirc2-0.1.tar.gz
  Running setup.py (path:/tmp/pip_build_root/pylirc2/setup.py) egg_info for package pylirc2

Installing collected packages: pylirc2
  Running setup.py install for pylirc2
    building 'pylircmodule' extension
    x86_64-linux-gnu-gcc -pthread -DNDEBUG -g -fwrapv -O2 -Wall -Wstrict-prototypes -g -fstack-protector --param=ssp-buffer-size=4 -Wformat -Werror=format-security -D_FORTIFY_SOURCE=2 -fPIC -I/usr/include/python3.4m -c pylircmodule.c -o build/temp.linux-x86_64-3.4/pylircmodule.o
    pylircmodule.c: In function ‘initpylirc’:
    pylircmodule.c:272:5: warning: implicit declaration of function ‘Py_InitModule’ [-Wimplicit-function-declaration]
         (void) Py_InitModule("pylirc", pylircMethods);
         ^
    x86_64-linux-gnu-gcc -pthread -shared -Wl,-O1 -Wl,-Bsymbolic-functions -Wl,-Bsymbolic-functions -Wl,-z,relro -Wl,-Bsymbolic-functions -Wl,-z,relro -g -fstack-protector --param=ssp-buffer-size=4 -Wformat -Werror=format-security -D_FORTIFY_SOURCE=2 build/temp.linux-x86_64-3.4/pylircmodule.o -llirc_client -o build/lib.linux-x86_64-3.4/pylircmodule.cpython-34m.so

Successfully installed pylirc2
Cleaning up...

> find /usr/local/lib/python3.4/ -name '*pylirc*'
/usr/local/lib/python3.4/dist-packages/pylircmodule.cpython-34m.so
/usr/local/lib/python3.4/dist-packages/pylirc2-0.1.egg-info

> strace python3 -c 'import pylirc'
...
open("<string>", O_RDONLY|O_CLOEXEC) = -1 ENOENT (No such file or directory)
open("<string>", O_RDONLY|O_CLOEXEC) = -1 ENOENT (No such file or directory)
open("/usr/lib/python3.4/<string>", O_RDONLY|O_CLOEXEC) = -1 ENOENT (No such file or directory)
open("/usr/lib/python3.4/plat-x86_64-linux-gnu/<string>", O_RDONLY|O_CLOEXEC) = -1 ENOENT (No such file or directory)
open("/usr/lib/python3.4/lib-dynload/<string>", O_RDONLY|O_CLOEXEC) = -1 ENOENT (No such file or directory)
open("/usr/local/lib/python3.4/dist-packages/<string>", O_RDONLY|O_CLOEXEC) = -1 ENOENT (No such file or directory)
open("/usr/lib/python3/dist-packages/<string>", O_RDONLY|O_CLOEXEC) = -1 ENOENT (No such file or directory)
write(2, "ImportError: No module named 'py"..., 38ImportError: No module named 'pylirc'

Question information

Language:
English Edit question
Status:
Solved
For:
Ubuntu pylirc Edit question
Assignee:
No assignee Edit question
Solved by:
Alexander Bubnov
Solved:
Last query:
Last reply:
Revision history for this message
Alexander Bubnov (alexander-bubnov) said :
#1

python3 -v key shows me additional information
...
Python 3.4.3 (default, Oct 14 2015, 20:28:29)
[GCC 4.8.4] on linux
Type "help", "copyright", "credits" or "license" for more information.
Traceback (most recent call last):
  File "<string>", line 1, in <module>
  File "<frozen importlib._bootstrap>", line 2237, in _find_and_load
  File "<frozen importlib._bootstrap>", line 2224, in _find_and_load_unlocked
ImportError: No module named 'pylirc'
...

Revision history for this message
actionparsnip (andrew-woodhead666) said :
#2

Mint is not supported here or in any of the Ubuntu support channels. The support of Mint (and the other "Ubuntu based" distributions) is entirely separate from Ubuntu's

I suggest you post on the Mint forum:
http://forums.linuxmint.com/

Revision history for this message
Alexander Bubnov (alexander-bubnov) said :
#3

it seems there is no PyModuleDef() method which needed for python3 :-(

Revision history for this message
actionparsnip (andrew-woodhead666) said :
#4

That is moot here. You need the Mint forum.

Revision history for this message
Alexander Bubnov (alexander-bubnov) said :
#5

It does not depened on distro. The root cause is that python3 does not use Py_InitModule(). It uses PyModuleDef() instead.
https://docs.python.org/3/howto/cporting.html

Revision history for this message
Mark Rijckenberg (markrijckenberg) said :
#6

No LSB modules are available.
Distributor ID: LinuxMint
Description: Linux Mint 17.3 Rosa
Release: 17.3
Codename: rosa

Linux Mint is not supported here. Only official Ubuntu variants are supported.

Please visit the following forum for support:

http://forums.linuxmint.com/

Revision history for this message
Alexander Bubnov (alexander-bubnov) said :
#7

Ok. I have tried on Lubuntu
> lsb_release -a
No LSB modules are available.
Distributor ID: Ubuntu
Description: Ubuntu 14.04.3 LTS
Release: 14.04
Codename: trusty

It is reproducible in the same way.

Revision history for this message
Alexander Bubnov (alexander-bubnov) said :
#8

I am sorry I just thought you are a developer team of pylirc.