0
votes

I want to use Python's emcee in Julia, so after a little research I found PyCall, then according to their documentation I had to use

using PyCall
@pyimport emcee

But I got this error

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

The Python package emcee could not be found by pyimport. Usually this means that you did not install emcee 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 emcee module, you can use pyimport_conda("emcee", PKG), where PKG is the Anaconda package the contains the module emcee, 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.

) ImportError('No module named emcee',)

So I found the directory where emcee is installed (/Users/Angel/anaconda/lib/python2.7) and I ran the command:

pyimport_conda("emcee","/Users/Angel/anaconda/lib/python2.7")

But I still get errors, this time

PackageNotFoundError: Packages missing in current channels:

  • /users/angel/anaconda/lib/python2.7

We have searched for the packages in the following channels:

So, what I'm doing wrong?

2
"/Users/Angel/anaconda/lib/python2.7" is not package name. You could try pyimport_conda("emcee","emcee", "astropy") - maybe it'll install emcee. If it doesn't help then you could try other way: ENV["PYTHON"] = "/Users/Angel/anaconda/lib/python2.7"; Pkg.build("PyCall") (and restart Julia). - Liso

2 Answers

1
votes

Do pip install <pkg> with the Python distribution used by Julia. Not all python packages can be installed using conda. For Windows/Linux/Mac x32,x64 check here: https://docs.anaconda.com/anaconda/packages/pkg-docs @pyimport emcee worked for me with no errors

1
votes

You can use emcee directly in julia. Here is the package

https://github.com/madsjulia/AffineInvariantMCMC.jl