# Pycall paths

**URL:** <https://discourse.julialang.org/t/pycall-paths/6985>\
**Category:** New to Julia\
**Tags:** pycall, python\
**Created:** [November 9, 2017, 11:38pm UTC](https://discourse.julialang.org/t/pycall-paths/6985 "2017-11-09T23:38:30Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![gideonsimpson](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/gideonsimpson/32/1928_2.png) [@gideonsimpson](https://discourse.julialang.org/u/gideonsimpson)\
**Post date:** [November 9, 2017, 11:38pm UTC](https://discourse.julialang.org/t/pycall-paths/6985/1 "2017-11-09T23:38:30Z")

</div>

So I have a python module that I want to load with pycall, but I’m struggling to get it working. I have anaconda 3 python installed on my system, separately from julia, and that python installation has all the usual things (i.e., numpy,scipy, etc.). However, If I try:

```julia
@pyimport scipy.optimize as so

```

I get the error:

```julia
PyError (ccall(@pysym(:PyImport_ImportModule), PyPtr, (Cstring,), name)

The Python package scipy.optimize could not be found by pyimport. Usually this means
that you did not install scipy.optimize in the Python version being used by PyCall.

PyCall is currently configured to use the Julia-specific Python distribution
installed by the Conda.jl package. To install the scipy.optimize module, you can
use `pyimport_conda("scipy.optimize", PKG)`, where PKG is the Anaconda
package the contains the module scipy.optimize, or alternatively you can use the
Conda package directly (via `using Conda` followed by `Conda.add` etcetera).

Alternatively, if you want to use a different Python distribution on your
system, such as a system-wide Python (as opposed to the Julia-specific Python),
you can re-configure PyCall with that Python. As explained in the PyCall
documentation, set ENV["PYTHON"] to the path/name of the python executable
you want to use, run Pkg.build("PyCall"), and re-launch Julia.

) <type 'exceptions.ImportError'>
ImportError('No module named scipy.optimize',)

```

And once I get that straightened out, I want to load a module which is in my `PYTHONPATH` when i open a shell, but is not in the standard location.

---

<div class="post-metadata">

**Author:** ![bernhard](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/bernhard/32/2619_2.png) [@bernhard](https://discourse.julialang.org/u/bernhard)\
**Post date:** [November 10, 2017, 8:41am UTC](https://discourse.julialang.org/t/pycall-paths/6985/2 "2017-11-10T08:41:44Z")

</div>

have you set the python environment variable?  
I think this can be done either in Windows or in Julia, but I am not quite sure  
Try something like this (in your Julia code)

```julia
ENV["PYTHON"]="C:\\JuliaPro-0.5.1.1\\Python\\python.exe"

```

---

<div class="post-metadata">

**Author:** ![stevengj](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/stevengj/32/71_2.png) [@stevengj](https://discourse.julialang.org/u/stevengj)\
**Post date:** [November 10, 2017, 12:49pm UTC](https://discourse.julialang.org/t/pycall-paths/6985/3 "2017-11-10T12:49:24Z")

</div>

> [@gideonsimpson](#):
>
> I have anaconda 3 python installed on my system, separately from julia, and that python installation has all the usual things (i.e., numpy,scipy, etc.). However, If I try:

By default, PyCall on Mac and Windows installs using its own Conda distribution, so it is probably not using your Anaconda Python. (Look at `PyCall.python` to see what it was configured with.)

To configure PyCall to use your own Python, set `ENV["PYTHON"]` to the `python` you want and re-run `Pkg.build("PyCall")`. This only needs to be done once, and PyCall will remember which `python` (technically which `libpython`) you want.
