0

I'm new to Python, so maybe there is a simple solution to this. I installed Anaconda and thought everything would be straightforward, but even though Jupyter works fine I can't import numpy and matplotlib into my notebook. Instead I get this error:

---------------------------------------------------------------------------
ImportError                               Traceback (most recent call last)
<ipython-input-1-1e0540761e0c> in <module>()
----> 1 import matplotlib.pyplot as plt
      2 vals = [1, 2, 3, 4]
      3 plt.plot(vals)

//anaconda/lib/python3.5/site-packages/matplotlib/__init__.py in <module>()
    120 # cbook must import matplotlib only within function
    121 # definitions, so it is safe to import from it here.
--> 122 from matplotlib.cbook import is_string_like, mplDeprecation, dedent, get_label
    123 from matplotlib.compat import subprocess
    124 from matplotlib.rcsetup import (defaultParams,

//anaconda/lib/python3.5/site-packages/matplotlib/cbook.py in <module>()
     31 from weakref import ref, WeakKeyDictionary
     32 
---> 33 import numpy as np
     34 import numpy.ma as ma
     35 

//anaconda/lib/python3.5/site-packages/numpy/__init__.py in <module>()
    144         return loader(*packages, **options)
    145 
--> 146     from . import add_newdocs
    147     __all__ = ['add_newdocs',
    148                'ModuleDeprecationWarning',

//anaconda/lib/python3.5/site-packages/numpy/add_newdocs.py in <module>()
     11 from __future__ import division, absolute_import, print_function
     12 
---> 13 from numpy.lib import add_newdoc
     14 
     15 ###############################################################################

//anaconda/lib/python3.5/site-packages/numpy/lib/__init__.py in <module>()
      6 from numpy.version import version as __version__
      7 
----> 8 from .type_check import *
      9 from .index_tricks import *
     10 from .function_base import *

//anaconda/lib/python3.5/site-packages/numpy/lib/type_check.py in <module>()
      9            'common_type']
     10 
---> 11 import numpy.core.numeric as _nx
     12 from numpy.core.numeric import asarray, asanyarray, array, isnan, \
     13                 obj2sctype, zeros

//anaconda/lib/python3.5/site-packages/numpy/core/__init__.py in <module>()
     12         os.environ[envkey] = '1'
     13         env_added.append(envkey)
---> 14 from . import multiarray
     15 for envkey in env_added:
     16     del os.environ[envkey]

ImportError: dlopen(//anaconda/lib/python3.5/site-packages/numpy/core/multiarray.so, 10): Symbol not found: _strnlen
  Referenced from: /anaconda/lib/python3.5/site-packages/numpy/core/../../../..//libmkl_intel_lp64.dylib
  Expected in: flat namespace
 in /anaconda/lib/python3.5/site-packages/numpy/core/../../../..//libmkl_intel_lp64.dylib

Since both packages show up in $ conda list its probably some kind of linking error(?), but that is unfortunately something a beginner can hardly solve for himself. Can anyone help?

6
  • At a first glance this looks like a serious problem with your installation as the error refers to some .dylib (DYnamic LIBrary) file which has to do with NumPy internals, not with your code. Commented Oct 11, 2016 at 16:21
  • @ForceBru I did nothing else than downloading & installing Anaconda, opening a Jupyter notebook and running a few simple scripts. Commented Oct 11, 2016 at 16:23
  • I see, but this is still a pretty odd error for me as it's complaining about the fact that the _strnlen C standard library symbol is missing, and this symbol is kinda standard, it should be present, but it isn't... Commented Oct 11, 2016 at 16:28
  • I am on a fairly old system (OS X 10.6.8), but I have Python 3.5 and all the packages installed fine and are up to date. Commented Oct 11, 2016 at 16:34
  • @ForceBru It seems that _strnlen is indeed missing in 10.6.8, see here and here. Is there a way to add it manually? It would be really depressing if I couldn't use SciPy due to this. Commented Oct 11, 2016 at 16:46

2 Answers 2

1

The key to your problem is possibly that you're running a pretty old Mac OS X version as _strnlen wasn't even available until 10.7 release.

Anaconda is built for at least OS X 10.7 (according to this), so you're probably out of luck here and a possible solution would be to upgrade the system.

Sign up to request clarification or add additional context in comments.

Comments

0

Okay so If I correctly understand what you are saying I propose that you add the package in the same folder your python file is located in. If possible add the code you have used to import the data so I can located any possible mistakes

4 Comments

The code is cited at the beginning of the error message.
Okay so did you try what I mentioned? The problem is that your problem can't locate the package thus, you get the error Expected in: flat namespace in /anaconda/lib/python3.5/site-packages/numpy/core/../../../..//libmkl_intel_lp64.dylib If what I mentioned initially doesn't work try adding your package in your python 3.5 folder in the folder packages
@LamprosTzanetos I tried to copy the numpy-1.11.2-py35_0 folder to the project dir, but that gives the same error message.
I have faced a similar problem in the past. You have to locate the packages folder not the project dir. If you can't find add you program files as well as the package in a new folder and try running the program again.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.