Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
510 views
in Technique[技术] by (71.8m points)

python - Failed scipy.special import "Symbol not found: ___addtf3"

Whenever I attempt to run this code:

from scipy.special import legendre

I keep encountering the following error.

ImportError: 

dlopen(/Users/william/miniconda/envs/myenv/lib/python3.4/site-packages/scipy/special/_ufuncs.so, 2): Symbol not found: ___addtf3
  Referenced from: /Users/william/miniconda/envs/prakenv/lib/python3.4/site-packages/scipy/special/_ufuncs.so
  Expected in: /usr/lib/libSystem.B.dylib

I've tried reverting to previous versions of scipy and using a Python 2.7 conda environment, but the problem persists. I have ever not had this problem before with scipy. Thank you very much!

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

I had a similar problem, except that I was installing scipy in a virtualenv using pip install -r requirements.txt, where one requirement was scipy==0.18.0. I finally resolved it by deleting my pip caches and trying again.

More specifically, I did this:

  1. Deactivate the virtualenv flask
  2. sudo rm -r flask/
  3. Checked my PATH and PYTHONPATH environment variables carefully, getting rid of references to other projects and other Python versions
  4. Set my MacPorts Python version to 2.7, consistent with my project's needs: Sudo port set python python27
  5. Delete my pip caches, rm -r ~/Library/Caches/pip/http/* ~/Library/Caches/pip/wheels/*
  6. Recreated the virtualenv: virtualenv flask
  7. Reactivated the virtualenv: source flask/bin/activate
  8. Performed a make operation which invoked pip install -r requirements.txt

I came up with a shorthand for detecting the problem:

% python -c 'import scipy.special'

When the problem occurred, I got an error response:

Traceback (most recent call last):
  File "<string>", line 1, in <module>
  File "/Users/myuser/project/flask/lib/python2.7/site-packages/scipy/special/__init__.py", line 636, in <module>
    from ._ufuncs import *
ImportError: dlopen(/Users/myuser/project/flask/lib/python2.7/site-packages/scipy/special/_ufuncs.so, 2): Symbol not found: ___addtf3
  Referenced from: /Users/myuser/project/flask/lib/python2.7/site-packages/scipy/special/../.dylibs/libquadmath.0.dylib
  Expected in: /usr/lib/libSystem.B.dylib
 in /Users/myuser/project/flask/lib/python2.7/site-packages/scipy/special/../.dylibs/libquadmath.0.dylib

When the problem was corrected, there was no output.

When the test was run in an environment without scipy (e.g. outside the virtualenv), there was the expected error:

ImportError: No module named scipy.special

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...