axiak / pyre2

Python wrapper for RE2
BSD 3-Clause "New" or "Revised" License
295 stars 39 forks source link

Found this error message while import re2 #51

Open noveneffendi opened 7 years ago

noveneffendi commented 7 years ago

my device is centos7. can you help me to solve this problem? ImportError: /usr/lib64/python2.7/site-packages/re2.so: undefined symbol: _ZNK3re23RE25MatchERKNS_11StringPieceEmmNS0_6AnchorEPS1_i

leewz commented 6 years ago

I got a similar error:

ImportError: /usr/local/lib/python3.5/dist-packages/re2.cpython-35m-x86_64-linux-gnu.so: undefined symbol: _ZN3re23RE27ReplaceEPNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEERKS0_RKNS_11StringPieceE

I installed the latest GCC (7,2.0):

sudo apt-get install gcc-7 g++-7

Aliased g++:

alias g++=g++-7

Re-make'd re2 (the C++ library)

make clean
sudo make install
make testinstall

Reinstalled pyre2 (just in case)

sudo python setup.py install
sudo python3 setup.py install

And it worked. Almost. (see #34 and #49)

>>> import re2
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "re2.pyx", line 1, in init re2 (src/re2.cpp:13681)
NameError: basestring

Python 3 removed the name basestring, so I needed to add it back in.

>>> __builtins__.basestring = str
>>> import re2
>>> #Success!