# Using Python nlopt on Slicer

**URL:** <https://discourse.slicer.org/t/using-python-nlopt-on-slicer/3404>\
**Category:** Development\
**Tags:** build, python\
**Created:** [July 6, 2018, 3:32pm UTC](https://discourse.slicer.org/t/using-python-nlopt-on-slicer/3404 "2018-07-06T15:32:27Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![chaddy1004](https://avatars.discourse-cdn.com/v4/letter/c/c2a13f/32.png) [@chaddy1004](https://discourse.slicer.org/u/chaddy1004)\
**Post date:** [July 6, 2018, 3:32pm UTC](https://discourse.slicer.org/t/using-python-nlopt-on-slicer/3404/1 "2018-07-06T15:32:28Z")

</div>

Hello

I am trying to use a library called [NLopt](https://nlopt.readthedocs.io/en/latest/) in Slicer for module development, but I am having a very difficult time getting it to work.

What I did was to download the .whl file of NLopt provided by the authors found [here](https://www.lfd.uci.edu/~gohlke/pythonlibs/#nlopt) and ran

```
pip.main(["install", "C:\Users\Stewart\Downloads\NLopt-2.4.2-cp27-cp27m-win_amd64.whl"]) 

```

It prompted that the install was successful, but when I try to import the module, I get the following error:

 ![image](https://us1.discourse-cdn.com/flex002/uploads/slicer/original/3X/d/5/d5eabd1e673d2aecdb5d6e6d21e203080f6d4fe3.png)

Then I built the source code of NLopt, then proceeded to place the .dll file in the Slicer Python’s site packages like so:  
 ![image](https://us1.discourse-cdn.com/flex002/uploads/slicer/original/3X/4/f/4f6b1e9375fd756897a393550921bd571fc86e83.png)  
but it still gives me the same errors.

When I pip install the .whl file through my command prompt and import it, it works fine.

I realize that this is a very specific question, but does anyone have any good suggestions on what to do, or got Python NLopt to work with Slicer?

Thank you!

Chad Paik

---

<div class="post-metadata">

**Author:** ![lassoan](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.slicer.org/lassoan/32/13_2.png) [@lassoan](https://discourse.slicer.org/u/lassoan)\
**Post date:** [July 7, 2018, 5:04am UTC](https://discourse.slicer.org/t/using-python-nlopt-on-slicer/3404/2 "2018-07-07T05:04:21Z")

</div>

Slicer uses Python 2.7, built using Visual Studio 2015. You need to build NLopt with Slicer’s Python, using Visual Studio 2015, similarly to how numpy is built. After we release Slicer-4.10, we’ll start migrating to Python3 and then it’ll be possible to pip install any packages.
