# PyCall: couldn't find libpython

**URL:** <https://discourse.julialang.org/t/pycall-couldnt-find-libpython/6116>\
**Category:** General Usage\
**Created:** [September 27, 2017, 3:22pm UTC](https://discourse.julialang.org/t/pycall-couldnt-find-libpython/6116 "2017-09-27T15:22:14Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![ExpandingMan](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/expandingman/32/866_2.png) [@ExpandingMan](https://discourse.julialang.org/u/ExpandingMan)\
**Post date:** [September 27, 2017, 3:22pm UTC](https://discourse.julialang.org/t/pycall-couldnt-find-libpython/6116/1 "2017-09-27T15:22:14Z")

</div>

I’m in the rather unfortunate position of having to use CentOS (unfortunate because everything on the latest version of CentOS is ancient). Anyway, of course there is no way of installing a reasonablly recent version of python 3 via the package manager (because nobody uses that, right?) so I’ve had to install python 3.6 using python’s `make`.

Anyway, the python interpreter itself seems to work ok. But when I try installing PyCall with my `python3` binary, it can’t seem to find the libraries.

```julia
LoadError: Couldn't find libpython; check your PYTHON environment variable.                                                                                                                                
                                                                                                                                                                                                               
The python executable we tried was /usr/local/bin/python3 (= version 3.6);                                                                                                                                    
the library names we tried were String["libpython3.6m.a", "libpython3.6m", "libpython3.6", "libpython"]                                                                                                 
and the library paths we tried were String["/usr/local/lib", "/usr/local/lib", "/usr/local", "/usr/local/lib"]                                                                                            
while loading /home/msavastio/.julia/v0.6/PyCall/deps/build.jl, in expression starting on line 255        

```

Thing is, `libpython3.6m.a` actually _is_ in `/usr/local/lib`. Obviously this is a static library, so PyCall shouldn’t be looking for it right? Do I have to figure out a way to get python to build that dynamic libraries, or is there something else wrong?

---

<div class="post-metadata">

**Author:** ![ihnorton](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/ihnorton/32/26_2.png) [@ihnorton](https://discourse.julialang.org/u/ihnorton)\
**Post date:** [September 27, 2017, 3:35pm UTC](https://discourse.julialang.org/t/pycall-couldnt-find-libpython/6116/2 "2017-09-27T15:35:14Z")

</div>

> [@ExpandingMan](#):
>
> Do I have to figure out a way to get python to build that dynamic libraries

Yes, there’s a flag for it.

(btw, have you checked [DevToolSet](https://www.softwarecollections.org/en/scls/rhscl/devtoolset-4/) for a suitable Python version? I believe they have some version of Python3)

---

<div class="post-metadata">

**Author:** ![ExpandingMan](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/expandingman/32/866_2.png) [@ExpandingMan](https://discourse.julialang.org/u/ExpandingMan)\
**Post date:** [September 27, 2017, 3:53pm UTC](https://discourse.julialang.org/t/pycall-couldnt-find-libpython/6116/3 "2017-09-27T15:53:08Z")

</div>

Hm… I’ve compiled the shared libraries (now have `libpython3.6m.so.1.0` and `libpython3.so` in `/usr/local/lib`) bit it still seems not to find them, throwing:

```julia
/usr/local/bin/python3: error while loading shared libraries: libpython3.6m.so.1.0: cannot open shared object file: No such file or directory

```

---

<div class="post-metadata">

**Author:** ![ExpandingMan](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/expandingman/32/866_2.png) [@ExpandingMan](https://discourse.julialang.org/u/ExpandingMan)\
**Post date:** [September 27, 2017, 5:05pm UTC](https://discourse.julialang.org/t/pycall-couldnt-find-libpython/6116/4 "2017-09-27T17:05:46Z")

</div>

Ok, the problem was that the compiled `python3` binary was using `LD_LIBRARY_PATH` instead of `ldconfig` or whatever it is that everything else uses when it links to all the usual locations. Fixed now.

---

<div class="post-metadata">

**Author:** ![Palli](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/palli/32/3380_2.png) [@Palli](https://discourse.julialang.org/u/Palli)\
**Post date:** [September 29, 2017, 12:07pm UTC](https://discourse.julialang.org/t/pycall-couldnt-find-libpython/6116/5 "2017-09-29T12:07:19Z")

</div>

I’m sure you’ve been given good advice already, just not sure if that way is needed.

It’s not completely clear from PyCall’s documentation that you can just use Conda to provide Python 3[.6] (not at all or only for non-Linux?). Python 3 is supported and Python 2 at least with Conda.

You can at least do ENV[“PYTHON”] = “” to get Python 2 from Conda (see doc). I did look a bit into the code and:

[https://github.com/JuliaPy/PyCall.jl/commit/bf2f7d46f2c5940062ffd55363fde0e2a22b5fd1#diff-ed74277d7f2e98f12cf51e6b8be90705](https://github.com/JuliaPy/PyCall.jl/commit/bf2f7d46f2c5940062ffd55363fde0e2a22b5fd1#diff-ed74277d7f2e98f12cf51e6b8be90705)
