Theano compilation error by using virtualenv and Python 2.7 on Fedora 31

Hi dear fedora community :slight_smile:

I have some troubles with using Theano Python library in virtualenv on Fedora 31.

Here is an error message which I get:
You can find the C code in this temporary file: /tmp/theano_compilation_error_K6DiVQ
Traceback (most recent call last):
File “process_data.py”, line 2, in
import theano
File “/home/olya/env_p27/lib/python2.7/site-packages/theano/init.py”, line 110, in
from theano.compile import (
File “/home/olya/env_p27/lib/python2.7/site-packages/theano/compile/init.py”, line 12, in
from theano.compile.mode import *
File “/home/olya/env_p27/lib/python2.7/site-packages/theano/compile/mode.py”, line 11, in
import theano.gof.vm
File “/home/olya/env_p27/lib/python2.7/site-packages/theano/gof/vm.py”, line 674, in
from . import lazylinker_c
File “/home/olya/env_p27/lib/python2.7/site-packages/theano/gof/lazylinker_c.py”, line 140, in
preargs=args)
File “/home/olya/env_p27/lib/python2.7/site-packages/theano/gof/cmodule.py”, line 2396, in compile_str
(status, compile_stderr.replace(’\n’, '. ')))
Exception: Compilation failed (return status=1): /home/olya/.theano/compiledir_Linux-5.3-fc31.x86_64-x86_64-with-fedora-31-Thirty_One-x86_64-2.7.17-64/lazylinker_ext/mod.cpp:1:10: error Python.h: no such file or catalog 1 | #include <Python.h>. | ^~~~~~~~~~. compilation was interrupted…

Here is output to “which theano” command in cmd:
/usr/bin/which: no theano in (/home/olya/env_p27/bin:/usr/share/Modules/bin:/usr/condabin:/usr/local/bin:/usr/local/sbin:/usr/bin:/usr/sbin:/home/olya/.local/bin:/home/olya/bin)

I already reinstall this package with pip, but it didn’t help. Maybe some of you had some similar problems like that? Thank you in advance :slight_smile:

Hi olya,

You may have found the answer already, but if not, I think that what you’re seeing is the result of python2.x getting dropped in Fedora 31.
I also used python2.7 in a virtualenv and when I checked the package changes before the upgrade, I noticed that virtualenv-related packages for 2.7 were going to be uninstalled. Sure enough, after the upgrade my existing virtual environments had similar issues.
Other than waiting for a python 3 port or choosing a distribution willing to support python 2 past its EOL, there are no options. The latter is going to be a bit risky.

Cheers

1 Like

Hello,

Potentially one way would be to set up a Fedora 30 toolbox container and install python2 in that.

toolbox create --release f30

However I would defer to others judgement on whether that is considered secure as the toolbox container still has access to your home directory and files.

1 Like

Python 2 was not removed from Fedora 31.

You need to install python2-devel for the Python headers. But even better at this point, don’t use Python 2. Theano supports Python 3, but also, it seems out of development for 2 years.

1 Like

Thank you very much, it helped :slight_smile:
Yes, python 2 and theano are quite obsolete technologies, but I needed to test smth with it :see_no_evil:

thank you very much for your advice :slight_smile: the solution was found

thank you very much for your advice, I did not test it, but other solution was found :slight_smile:

This topic was automatically closed 28 days after the last reply. New replies are no longer allowed.