Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

PyCall unable to use pipenv version of python InitError:Incompatible `libpython` detected

Following the instructions on the PyCall.jl readme, I am tying to use a pipenv python when using PyCall for my julia project (in it's own environment).

In a terminal, I have activated the python environment using pipenv shell, and then located the pathfile of the pipenv version of python. PyCall has already been added to the manifest in my julia environment. In the source-activated terminal, I started Julia and entered: ENV["PYCALL_JL_RUNTIME_PYTHON"] = pipenv python environmentand then proceeded to run Pkg.build("PyCall"), which installs conda. When importing PyCall - using PyCall - I get the following error.

ERROR: InitError: Incompatible `libpython` detected.
`libpython` for C:\Users\me\.virtualenvs\iap\Scripts\python.exe is:
    C:\Users\me\.virtualenvs\iap\Scripts\python37.dll
`libpython` for C:\Users\me\.julia\conda\3\python.exe is:
    C:\Users\me\.julia\conda\3\python36.dll
PyCall.jl only supports loading Python environment using the same `libpython`

I've tried re-installing PyCall, but the python environment libpython always throws this error. How can I override or otherwise work around the conda requirement for base julia?

I have a feeling that the Conda dependency of PyCall is causing some libpython issue, and that the ENV["PYCALL_JL_RUNTIME_PYTHON"] call doesn't override the libpython variable properly.

like image 292
PeptideWitch Avatar asked Oct 28 '22 03:10

PeptideWitch


1 Answers

According to the documentation PyCall supports venv and virtualenv environments, but you are using pipenv. I recommend you try with either of the supported alternatives, if you want to use the PYCALL_JL_RUNTIME_PYTHON variable.

If you want to use continue using the pipenv environment instead, you probably have to specify the PYTHON variable instead in your startup.jl configuration file, like this:

ENV["PYTHON"] = "C:\\path\\to\\your\\pipenv\\python.exe"

Then run:

julia> using Pkg; Pkg.build("PyCall"); using PyCall
like image 148
HarmonicaMuse Avatar answered Nov 15 '22 07:11

HarmonicaMuse