title: C++ - Python Embedding with numpy
body: <p>I would like to call a python function from C++ and get the return value. I've been able to do that with an easy multiply python function using <a href="https://docs.python.org/2/extending/embedding.html" rel="nofollow noreferrer">this</a> website's example code in section 5.3. To compile my program, I would run <code>g++ test.cpp -I/usr/include/python2.7 -lpython2.7</code>. However, the python function I want to run imports numpy. When I try to run my program that is similar to the one on the code example mentioned above, I get an "ImportError: cannot import name _remove_dead_weakref". The full error is here:</p>
  
  <pre><code>Traceback (most recent call last):
    File "/home/osboxes/Desktop/test.py", line 1, in &lt;module&gt;
      import numpy as np 
    File "/home/osboxes/.local/lib/python2.7/site-packages/numpy/__init__.py", line 142, in &lt;module&gt;
      from . import add_newdocs
    File "/home/osboxes/.local/lib/python2.7/site-packages/numpy/add_newdocs.py", line 13, in &lt;module&gt;
      from numpy.lib import add_newdoc
    File "/home/osboxes/.local/lib/python2.7/site-packages/numpy/lib/__init__.py", line 8, in &lt;module&gt;
      from .type_check import *
    File "/home/osboxes/.local/lib/python2.7/site-packages/numpy/lib/type_check.py", line 11, in &lt;module&gt;
      import numpy.core.numeric as _nx
    File "/home/osboxes/.local/lib/python2.7/site-packages/numpy/core/__init__.py", line 74, in &lt;module&gt;
      from numpy.testing.nosetester import _numpy_tester
    File "/home/osboxes/.local/lib/python2.7/site-packages/numpy/testing/__init__.py", line 10, in &lt;module&gt;
      from unittest import TestCase
    File "/home/osboxes/miniconda2/lib/python2.7/unittest/__init__.py", line 64, in &lt;module&gt;
      from .main import TestProgram, main
    File "/home/osboxes/miniconda2/lib/python2.7/unittest/main.py", line 7, in &lt;module&gt;
      from . import loader, runner
    File "/home/osboxes/miniconda2/lib/python2.7/unittest/runner.py", line 7, in &lt;module&gt;
      from .signals import registerResult
    File "/home/osboxes/miniconda2/lib/python2.7/unittest/signals.py", line 2, in &lt;module&gt;
      import weakref
    File "/home/osboxes/miniconda2/lib/python2.7/weakref.py", line 14, in &lt;module&gt;
      from _weakref import (
  ImportError: cannot import name _remove_dead_weakref
  </code></pre>
  
  <p>Some information: Python version is Python 2.7.14 :: Anaconda, Inc. (Is there a difference between python 2.7.14 and my version which has anaconda, inc. at the end?) The python program also runs just fine by itself. Any help would be appreciated. Thanks!</p>
  
  <p>Edit: The path was being all weird with some parts going to my local python and numpy going to miniconda's python. Uninstalling miniconda as it wasn't needed for me fixed it.</p>