Skip to content
This repository has been archived by the owner on Jul 10, 2021. It is now read-only.

installed from pip, but can not import. #215

Open
swuecho opened this issue Jul 7, 2016 · 7 comments
Open

installed from pip, but can not import. #215

swuecho opened this issue Jul 7, 2016 · 7 comments

Comments

@swuecho
Copy link

swuecho commented Jul 7, 2016

Could anyone have a look? Thanks.

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "nn.py", line 5, in <module>
    from sknn.mlp import Classifier, Layer
  File "/home/hwu/.pyenv/versions/MS/lib/python3.5/site-packages/sknn/mlp.py", line 18, in <module>
    import theano
  File "/home/hwu/.pyenv/versions/MS/lib/python3.5/site-packages/theano/__init__.py", line 63, in <module>
    from theano.compile import (
  File "/home/hwu/.pyenv/versions/MS/lib/python3.5/site-packages/theano/compile/__init__.py", line 9, in <module>
    from theano.compile.function_module import *
  File "/home/hwu/.pyenv/versions/MS/lib/python3.5/site-packages/theano/compile/function_module.py", line 22, in <module>
    import theano.compile.mode
  File "/home/hwu/.pyenv/versions/MS/lib/python3.5/site-packages/theano/compile/mode.py", line 12, in <module>
    import theano.gof.vm
  File "/home/hwu/.pyenv/versions/MS/lib/python3.5/site-packages/theano/gof/vm.py", line 638, in <module>
    from . import lazylinker_c
  File "/home/hwu/.pyenv/versions/MS/lib/python3.5/site-packages/theano/gof/lazylinker_c.py", line 126, in <module>
    preargs=args)
  File "/home/hwu/.pyenv/versions/MS/lib/python3.5/site-packages/theano/gof/cmodule.py", line 2204, in compile_str
    (status, compile_stderr.replace('\n', '. ')))
Exception: Compilation failed (return status=1): /usr/bin/ld: /home/hwu/.pyenv/versions/3.5.0/lib/libpython3.5m.a(abstract.o): relocation R_X86_64_32S against `_Py_NotImplementedStruct' can not be used when making a shared object; recompile with -fPIC. /home/hwu/.pyenv/versions/3.5.0/lib/libpython3.5m.a: could not read symbols: Bad value. collect2: ld returned 1 exit status.

@alexjc
Copy link
Member

alexjc commented Jul 8, 2016

The bottom line indicates a problem with versioning, likely Theano issue?

@swuecho
Copy link
Author

swuecho commented Jul 8, 2016

upgrade does not work either.

 pip install scikit-neuralnetwork --upgrade
Requirement already up-to-date: scikit-neuralnetwork in /home/hwu/.pyenv/versions/MS/lib/python3.5/site-packages
Requirement already up-to-date: scikit-learn>=0.17 in /home/hwu/.pyenv/versions/MS/lib/python3.5/site-packages (from scikit-neuralnetwork)
Requirement already up-to-date: Lasagne>=0.1 in /home/hwu/.pyenv/versions/MS/lib/python3.5/site-packages (from scikit-neuralnetwork)
Requirement already up-to-date: Theano>=0.8 in /home/hwu/.pyenv/versions/MS/lib/python3.5/site-packages (from scikit-neuralnetwork)
Requirement already up-to-date: numpy in /home/hwu/.pyenv/versions/MS/lib/python3.5/site-packages (from Lasagne>=0.1->scikit-neuralnetwork)
Requirement already up-to-date: six>=1.9.0 in /home/hwu/.pyenv/versions/MS/lib/python3.5/site-packages (from Theano>=0.8->scikit-neuralnetwork)
Requirement already up-to-date: scipy>=0.11 in /home/hwu/.pyenv/versions/MS/lib/python3.5/site-packages (from Theano>=0.8->scikit-neuralnetwork)

@alexjc
Copy link
Member

alexjc commented Jul 12, 2016

Is this a fresh install? Likely you need to start from scratch, make sure there are no conflicts inside/outside your virtual env.

@MaxHoefl
Copy link

I am getting precisely the same error on import theano

Compilation failed (return status=1): /usr/bin/ld: /share/apps/python-3.5.1/lib/libpython3.5m.a(abstract.o): relocation R_X86_64_32S against `_Py_NotImplementedStruct' can not be used when making a shared object; recompile with -fPIC. /share/apps/python-3.5.1/lib/libpython3.5m.a: could not read symbols: Bad value. collect2: ld returned 1 exit status.

I also tried the flag [gcc] cxxflags = -march=corei7 but it gives me

 Compilation failed (return status=1): /home/mhoefl/.theano/compiledir_Linux-2.6-el6.x86_64-x86_64-with-centos-6.5-Final-x86_64-3.5.1-64/lazylinker_ext/mod.cpp:1: error: bad value (corei7) for -march= switch. /home/mhoefl/.theano/compiledir_Linux-2.6-el6.x86_64-x86_64-with-centos-6.5-Final-x86_64-3.5.1-64/lazylinker_ext/mod.cpp:1: error: bad value (corei7) for -mtune= switch.

@pingdong90
Copy link

@MaxHoefl

please ensure the config file ~/.theanorc, cxxflags = -march=native

@DeoLeung
Copy link

DeoLeung commented Feb 8, 2017

@pingdong90
I encountered the same situation

I'm running python3.5.2 under virtual env on a centos7 box

I tried re-install python with --enable-shared as some StackOverflow posts and add the config file

[gcc]
cxxflags = -march=native

but still not working

@eddieantonio
Copy link

Hello all,

If you're using pyenv, the reason is simple: when pyenv builds Python, it doesn't allow shared (dynamic) library linkage by default. So you need to rebuild with --enabled-shared:

$ env PYTHON_CONFIGURE_OPTS="--enable-shared" pyenv install 3.6.0

Then, when Theano builds (recall that it's complaining about recompiling with -fPIC), it is able to link with shared libraries.

This resolved this issue for me! 😄

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

6 participants