python3.4: pylirc module not loaded although is installed on my system - python-3.4

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'
As you can see from strace python does not try finding pylirc in its paths. And it is strange (or it is not?). Somehow python is finding < string > instead of something pylirc.
What the magic happens here? :-)
more information:
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'
...

It seems pylirc c module does not compatible with python3. Because pylirc does not call PyModule_Create() as describe here https://docs.python.org/3/howto/cporting.html.
The code of pylirc https://github.com/offlinehacker-playground/pylirc2/blob/master/pylircmodule.c

Related

Microsoft R Open + line breaks during package compilation

For some odd reason, the latest version of Microsoft R Open is failing to compile various packages, because of something (Rcpp I think) that spawns multiple R sessions, and the repeated calls to clear the terminal window are introducing line breaks in the middle of the compiler commands. See below. There doesn't seem to be a reliable way to completely suppress the verbose startup message, which appears to be causing this error.
Note the same happens with /opt/microsoft/ropen/4.0.2/lib64/R/bin/R CMD INSTALL as well as /opt/microsoft/ropen/4.0.2/lib64/R/bin/Rscript
Ideas? Suggestions?
$ /opt/microsoft/ropen/4.0.2/lib64/R/bin/R -q
> install.packages('minqa')
Installing package into ‘/raid/users/g-socsldap/R/x86_64-pc-linux-gnu-library/4.0’
(as ‘lib’ is unspecified)
% Total % Received % Xferd Average Speed Time Time Time Current
Dload Upload Total Spent Left Speed
100 53548 100 53548 0 0 247k 0 --:--:-- --:--:-- --:--:-- 247k
Microsoft R Open 4.0.2
The enhanced R distribution from Microsoft
Microsoft packages Copyright (C) 2020 Microsoft Corporation
Using the Intel MKL for parallel mathematical computing (using 44 cores).
Default CRAN mirror snapshot taken on 2020-07-16.
See: https://mran.microsoft.com/.
* installing *source* package ‘minqa’ ...
** package ‘minqa’ successfully unpacked and MD5 sums checked
** using staged installation
** libs
gfortran -fpic -g -O2 -c altmov.f -o altmov.o
gfortran -fpic -g -O2 -c bigden.f -o bigden.o
gfortran -fpic -g -O2 -c biglag.f -o biglag.o
gfortran -fpic -g -O2 -c bobyqa.f -o bobyqa.o
gfortran -fpic -g -O2 -c bobyqb.f -o bobyqb.o
gfortran -fpic -g -O2 -c lagmax.f -o lagmax.o
g++ -I/opt/microsoft/ropen/4.0.2/lib64/R/include -DNDEBUG -I'/opt/microsoft/ropen/4.0.2/lib64/R/library/Rcpp/include' -DU_STATIC_IMPLEMENTATION -fpic -DU_STATIC_IMPLEMENTATION -O2 -g -c minqa.cpp -o minqa.o
gfortran -fpic -g -O2 -c newuoa.f -o newuoa.o
gfortran -fpic -g -O2 -c newuob.f -o newuob.o
gfortran -fpic -g -O2 -c prelim.f -o prelim.o
gfortran -fpic -g -O2 -c rescue.f -o rescue.o
gfortran -fpic -g -O2 -c trsapp.f -o trsapp.o
gfortran -fpic -g -O2 -c trsbox.f -o trsbox.o
gfortran -fpic -g -O2 -c trstep.f -o trstep.o
gfortran -fpic -g -O2 -c uobyqa.f -o uobyqa.o
gfortran -fpic -g -O2 -c uobyqb.f -o uobyqb.o
gfortran -fpic -g -O2 -c update.f -o update.o
gfortran -fpic -g -O2 -c updatebobyqa.f -o updatebobyqa.o
g++ -shared -L/opt/microsoft/ropen/4.0.2/lib64/R/lib -o minqa.so altmov.o bigden.o biglag.o bobyqa.o bobyqb.o lagmax.o minqa.o newuoa.o newuob.o prelim.o rescue.o trsapp.o trsbox.o trstep.o uobyqa.o uobyqb.o update.o updatebobyqa.o Microsoft R Open 4.0.2 The enhanced R distribution from Microsoft Microsoft packages Copyright (C) 2020 Microsoft Corporation Using the Intel MKL for parallel mathematical computing (using 44 cores). Default CRAN mirror snapshot taken on 2020-07-16. See: https://mran.microsoft.com/. -lgfortran -lm -L/opt/microsoft/ropen/4.0.2/lib64/R/lib -lR
g++: error: Microsoft: No such file or directory
g++: error: R: No such file or directory
g++: error: Open: No such file or directory
g++: error: 4.0.2: No such file or directory
g++: error: The: No such file or directory
g++: error: enhanced: No such file or directory
g++: error: R: No such file or directory
g++: error: distribution: No such file or directory
g++: error: from: No such file or directory
g++: error: Microsoft: No such file or directory
g++: error: Microsoft: No such file or directory
g++: error: packages: No such file or directory
g++: error: Copyright: No such file or directory
g++: error: (C): No such file or directory
g++: error: 2020: No such file or directory
g++: error: Microsoft: No such file or directory
g++: error: Corporation: No such file or directory
g++: error: Using: No such file or directory
g++: error: the: No such file or directory
g++: error: Intel: No such file or directory
g++: error: MKL: No such file or directory
g++: error: for: No such file or directory
g++: error: parallel: No such file or directory
g++: error: mathematical: No such file or directory
g++: error: computing: No such file or directory
g++: error: (using: No such file or directory
g++: error: 44: No such file or directory
g++: error: cores).: No such file or directory
g++: error: Default: No such file or directory
g++: error: CRAN: No such file or directory
g++: error: mirror: No such file or directory
g++: error: snapshot: No such file or directory
g++: error: taken: No such file or directory
g++: error: on: No such file or directory
g++: error: 2020-07-16.: No such file or directory
g++: error: See:: No such file or directory
g++: error: https://mran.microsoft.com/.: No such file or directory
make: *** [/opt/microsoft/ropen/4.0.2/lib64/R/share/make/shlib.mk:6: minqa.so] Error 1
ERROR: compilation failed for package ‘minqa’
* removing ‘/raid/users/g-socsldap/R/x86_64-pc-linux-gnu-library/4.0/minqa’
The downloaded source packages are in
‘/tmp/RtmpMlXevk/downloaded_packages’
Warning message:
In install.packages("minqa") :
installation of package ‘minqa’ had non-zero exit status
I figured this problem with running R in --vanilla mode (this mode ignores .Rprofile.site located in /opt/microsoft/ropen/4.0.2/lib64/R/etc/Rprofile.site):
R --vanilla
install.packages("minqa")
// select any link you want

Torch '!./install.sh' returns error in Colab when installing Torch

I followed http://torch.ch/docs/getting-started.html#_ to install Torch.
I always get the following error when running
!./install.sh
in google colab
error:
...
-- Installing: /root/torch/install/include/luaT.h
-- Installing: /root/torch/install/share/cmake/torch/luaTConfig.cmake
Updating manifest for /root/torch/install/lib/luarocks/rocks
torch scm-1 is now built and installed in /root/torch/install/ (license: BSD)
Updating manifest for /root/torch/install/lib/luarocks/rocks
dok scm-1 is now built and installed in /root/torch/install/ (license: BSD)
gcc -O2 -fPIC -I/root/torch/install/include -c utils.c -o utils.o
gcc -shared -o treplutils.so -L/root/torch/install/lib utils.o
gcc -O2 -fPIC -I/root/torch/install/include -c readline.c -o readline.o
readline.c:8:10: fatal error: readline/readline.h: No such file or directory
#include <readline/readline.h>
^~~~~~~~~~~~~~~~~~~~~
compilation terminated.
Error: Build error: Failed compiling object readline.o
.
Please I need help fixing this error.
Probably you need something like
!apt-get install libreadline-dev
before attempting to run the install.sh script.

building a mapnik 2.2.0 RPM on RHEL 7

I am trying to build a mapnik 2.2.0 RPM file on my RHEL/CENTOS 7 machine.
so I took the RPM SRC file from Fedora 22 which is mapnik-2.2.0-11.fc21.src.rpm ( I have the same result with mapnik-2.2.0-5.fc20.src.rpm )
when I am running the rpmbuild I receive the following error message:
Welcome to Mapnik...
scons: warning: Ignoring missing SConscript 'deps/agg/build.py'
File "/root/rpmbuild/BUILD/mapnik-v2.2.0/SConstruct", line 1799, in <module>
scons: warning: Ignoring missing SConscript 'deps/mapnik/build.py'
File "/root/rpmbuild/BUILD/mapnik-v2.2.0/SConstruct", line 1808, in <module>
scons: done reading SConscript files.
scons: Building targets ...
g++ -o bindings/python/mapnik_building_symbolizer.os -c -ansi -Wall -pthread -ftemplate-depth-300 -O3 -O2 -g -pipe -Wall -Wp,-D_FORTIFY_SOURCE=2 -fexceptions -fstack-protector-strong --param=ssp-buffer-size=4 -grecord-gcc-switches -m64 -mtune=generic -fno-strict-aliasing -finline-functions -Wno-inline -Wno-parentheses -Wno-char-subscripts -fPIC -DHAVE_JPEG -DMAPNIK_USE_PROJ4 -DHAVE_PNG -DHAVE_TIFF -DBIGINT -DBOOST_REGEX_HAS_ICU -DLINUX -DMAPNIK_THREADSAFE -DNDEBUG -DHAVE_CAIRO -DHAVE_PYCAIRO -I. -Iinclude -I/usr/include/polyclipping -I/usr/include/agg2 -I/usr/include -I/usr/include/freetype2 -I/usr/include/libxml2 -I/usr/include/gdal -I/usr/include/python2.7 -I/usr/include/cairo -I/usr/include/glib-2.0 -I/usr/lib64/glib-2.0/include -I/usr/include/pixman-1 -I/usr/include/libpng15 -I/usr/include/libdrm -I/usr/include/pycairo bindings/python/mapnik_building_symbolizer.cpp
In file included from include/mapnik/symbolizer.hpp:29:0,
from include/mapnik/building_symbolizer.hpp:29,
from bindings/python/mapnik_building_symbolizer.cpp:26:
include/mapnik/image_compositing.hpp:74:19: error: 'comp_op_grain_merge' is not a member of 'agg'
grain_merge = agg::comp_op_grain_merge,
^
include/mapnik/image_compositing.hpp:75:21: error: 'comp_op_grain_extract' is not a member of 'agg'
grain_extract = agg::comp_op_grain_extract,
^
scons: *** [bindings/python/mapnik_building_symbolizer.os] Error 1
scons: building terminated because of errors.
error: Bad exit status from /var/tmp/rpm-tmp.kuI6KW (%build)
RPM build errors:
Bad exit status from /var/tmp/rpm-tmp.kuI6KW (%build)
Mapnik normally comes with a heavily patched version of the AGG library right there in its source tree. The Fedora build however disables that in favour of having the Mapnik-AGG patches directly in its own AGG package (because they don't like duplicating system libraries elsewhere).
You either need an AGG library for CentOS that is feature-compatible with the patched Fedora version, or you have to modify your Mapnik build to disable the "system_agg" patch (and drop the "rm -rf boost deps" from the spec file).

Unable to install pyrocksdb against RocksDB master

I followed the instructions from here: http://pyrocksdb.readthedocs.org/en/latest/installation.html
When I try pip install git+git://github.com/stephan-hof/pyrocksdb.git I get the following output with error:
running install
running build
running build_py
creating build
creating build/lib.linux-x86_64-3.4
creating build/lib.linux-x86_64-3.4/rocksdb
copying rocksdb/__init__.py -> build/lib.linux-x86_64-3.4/rocksdb
copying rocksdb/interfaces.py -> build/lib.linux-x86_64-3.4/rocksdb
copying rocksdb/errors.py -> build/lib.linux-x86_64-3.4/rocksdb
creating build/lib.linux-x86_64-3.4/rocksdb/tests
copying rocksdb/tests/__init__.py -> build/lib.linux-x86_64-3.4/rocksdb/tests
copying rocksdb/tests/test_db.py -> build/lib.linux-x86_64-3.4/rocksdb/tests
copying rocksdb/tests/test_options.py -> build/lib.linux-x86_64-3.4/rocksdb/tests
running egg_info
creating pyrocksdb.egg-info
writing dependency_links to pyrocksdb.egg-info/dependency_links.txt
writing top-level names to pyrocksdb.egg-info/top_level.txt
writing requirements to pyrocksdb.egg-info/requires.txt
writing pyrocksdb.egg-info/PKG-INFO
writing manifest file 'pyrocksdb.egg-info/SOURCES.txt'
warning: manifest_maker: standard file '-c' not found
reading manifest file 'pyrocksdb.egg-info/SOURCES.txt'
writing manifest file 'pyrocksdb.egg-info/SOURCES.txt'
copying rocksdb/_rocksdb.cpp -> build/lib.linux-x86_64-3.4/rocksdb
running build_ext
building 'rocksdb._rocksdb' extension
creating build/temp.linux-x86_64-3.4
creating build/temp.linux-x86_64-3.4/rocksdb
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/home/iulian/py3env/include -I/usr/include/python3.4m -c rocksdb/_rocksdb.cpp -o build/temp.linux-x86_64-3.4/rocksdb/_rocksdb.o -std=gnu++11 -O3 -Wall -Wextra -Wconversion -fno-strict-aliasing
cc1plus: warning: command line option ‘-Wstrict-prototypes’ is valid for C/ObjC but not for C++ [enabled by default]
rocksdb/_rocksdb.cpp:289:27: fatal error: rocksdb/slice.h: No such file or directory
#include "rocksdb/slice.h"
^
compilation terminated.
error: command 'x86_64-linux-gnu-gcc' failed with exit status 1
----------------------------------------
Command "/home/iulian/py3env/bin/python -c "import setuptools, tokenize;__file__='/tmp/pip-mndoekm3-build/setup.py';exec(compile(getattr(tokenize, 'open', open)(__file__).read().replace('\r\n', '\n'), __file__, 'exec'))" install --record /tmp/pip-3fwa2_ff-record/install-record.txt --single-version-externally-managed --compile --install-headers /home/iulian/py3env/include/site/python3.4" failed with error code 1 in /tmp/pip-mndoekm3-build
I tried to checkout various versions of RocksDB (3.5, 3.6, 3.8, 3.9) and still no luck.
I am using Python 3.4 on a 64 bit Ubuntu 14.04.
You have to check that Cython==0.20 is installed! I had the same issue and that solved it!

Issue including std::vector to cython

I have a problem importing the vector class to cython using
from libcpp.vector cimport vector
when I add this and try to compile the pyx file I get
python setup.py build_ext --inplace
running build_ext
skipping 'kmc_cy.c' Cython extension (up-to-date)
building 'kmc_cy' extension
gcc -pthread -fno-strict-aliasing -g -O2 -DNDEBUG -fmessage-length=0 -O2 -Wall -D_FORTIFY_SOURCE=2 -fstack-protector -funwind-tables -fasynchronous-unwind-tables -g -fPIC -I/usr/include/python2.7 -c kmc_cy.c -o build/temp.linux-x86_64-2.7/kmc_cy.o
kmc_cy.c:254:18: fatal error: vector: No such file or directory
compilation terminated.
error: command 'gcc' failed with exit status 1
Here is my setup.py
from distutils.core import setup
from distutils.extension import Extension
from Cython.Distutils import build_ext
import sys
sys.path.append("/usr/lib64/python2.7/site-packages/Cython/Includes/libcpp")
ext_modules = [Extension("kmc_cy", ["kmc_cy.pyx"])]
setup(
name = 'kmc_cy',
cmdclass = {'build_ext': build_ext},
ext_modules = ext_modules,
)
Cheers
As std::vector is C++ code, you need to set the correct language:
ext_modules = [Extension("kmc_cy", ["kmc_cy.pyx"],language='c++')]
Then g++ should be used instead of gcc and the file name should end with .cpp or .cc.
See this answer for more details.

Resources