ibanez221
ibanez221

Reputation: 145

boost module in Python 2.7?

I am trying to debug a file for a project I am working on, and the first thing I made sure to do is install/build all of the modules that the file is importing. Thisis the first line of the file:

from scitbx.array_family import flex

which in turn reads from flex.py,

from __future__ import division
import boost.optional # import dependency
import boost.std_pair # import dependency
import boost.python    

I entered the commands in ipython individually and get stuck on importing boost.optional. Since they are all from the same module I tried searching for the module named boost.

I found the site: http://www.boost.org/doc/libs/1_57_0/more/getting_started/unix-variants.html

and installed the related .bz2 file in the same directory as my other modules to make sure it is within sys.path. However I still can't get ipython to import anything. Am I completely off base in my approach or is there some other boost module that I can't find? I should mention that I am a complete novice with computers, and am learning as I go along. Any advice is much appreciated!

Upvotes: 1

Views: 2924

Answers (1)

Mark Streatfield
Mark Streatfield

Reputation: 3209

The library you have installed is called Boost. This is a collection of C++ libraries, one of which is Boost.Python. However this library doesn't provide Python modules that you can import directly - it doesn't provide boost.optional. Instead it enables interoperability between Python and C++ - you can write a C++ library using Boost.Python that can then be used in a normal Python interpreter.

In you case boost.optional is provided by the CCTBX collection of software, which does depend on Boost and Boost.Python. So you are not too far off. This thread in the mailing list covers your error message and some potential solutions.

Essentially you need to use the custom cctbx.python command (or scitbx.python, they are equivalent) to run python as this sets the PYTHONPATH correctly for their requirements. It's also documented on this page.

Upvotes: 2

Related Questions