title: Swig wrapping C++ to python is using default Python rather than Anaconda python in Mac OS X
body: <p>I am trying to wrap c++ functions into python using swig. I am using following commands  </p>
  
  <pre><code>swig -c++ -python helloworld.i
  g++ -O2 -fPIC -c hello.cpp
  g++ -O2 -fPIC -c helloworld_wrap.cxx -I//anaconda/include/python2.7
  g++ -lpython -dynamclib hello.o helloworld_wrap.o -o _helloworld.so
  </code></pre>
  
  <p>with <code>hello.cpp</code> being initial file with functions and <code>helloworld.i</code> being file with wrapper. These commands creates the library <code>helloworld</code>but I can only import it through default python in <code>/usr/bin/python</code>  </p>
  
  <p>If I try to import it through <code>python</code> installed through anaconda it gives following error:  </p>
  
  <pre><code>Fatal Python error: PyThreadState_Get: no current thread
  Abort trap: 6  
  </code></pre>
  
  <p>Can you tell me how can I wrap the codes with <code>python</code> from anaconda? </p>
  
  <p>Found a solution : <a href="https://stackoverflow.com/questions/25882150/python-h-not-found-using-swig-and-anaconda-python">Python.h not found using swig and Anaconda Python</a>  </p>
  
  <p>In above question, the top answer gives an explanation of using <code>disutils</code>and a set up file in python to build the library. This works wonders :) </p>
  
  <p>The next problem I am having for wrapping simple class:  </p>
  
  <p>my class code from [example] (<a href="http://web.mit.edu/svn/src/swig-1.3.25/Examples/python/class/index.html" rel="nofollow noreferrer">http://web.mit.edu/svn/src/swig-1.3.25/Examples/python/class/index.html</a>)  </p>
  
  <pre><code>/* File : example.h */
  
  class Shape {
  public:
    Shape() {
      nshapes++;
    }
    virtual ~Shape() {
      nshapes--;
    };
    double  x, y;   
    void    move(double dx, double dy);
    virtual double area() = 0;
    virtual double perimeter() = 0;
    static  int nshapes;
  };
  
  class Circle : public Shape {
      private:
    double radius;
  public:
    Circle(double r) : radius(r) { };
    virtual double area();
    virtual double perimeter();
  };
  
  class Square : public Shape {
  private:
    double width;
  public:
    Square(double w) : width(w) { };
    virtual double area();
    virtual double perimeter();
  };  
  </code></pre>
  
  <p>My <code>setup.py</code> file :    </p>
  
  <pre><code>#setup.py file:
  
  from setuptools import setup, Extension
  
  setup(name='example',
  
      version='0.1',
  
      ext_modules=[Extension('_example', ['example.h', 'example.i'],
                  swig_opts=['-c++'],
                  )],
  
      )  
  </code></pre>
  
  <p>Code I am using to wrap :   </p>
  
  <pre><code>python setup.py build_ext --inplace  
  </code></pre>
  
  <p>Error message:   </p>
  
  <pre><code>running build_ext
  building '_example' extension
  swigging example.i to example_wrap.cpp
  swig -python -c++ -o example_wrap.cpp example.i
  error: unknown file type '.h' (from 'example.h')  
  </code></pre>
  
  <p>Can you suggest what is wrong here. I suppose it is not recognizing '.h' file but as it is header file, I thought it could be kept as it is. Also if my <code>setup.py</code> file is correct or not? I am just trying to follow example for simple wrapping, there is no simple tutorial online apparently.<br>
  I can also ask this question on other different question but thought just continuing here for now. </p>