How to use Python library in Julia?

I was wondering how can I use this package https://github.com/DeepGraphLearning/ConfGF in Julia by using PyCall.jl or PythonCall.jl?

this is how to use this package in python. I want to do it in Julia, is it feasible?

# Create conda environment
conda create -n confgf python=3.7

# Activate the environment
conda activate confgf

# Install packages
conda install -y -c pytorch pytorch=1.7.0 torchvision torchaudio cudatoolkit=10.2
conda install -y -c rdkit rdkit==2020.03.2.0
conda install -y scikit-learn pandas decorator ipython networkx tqdm matplotlib
conda install -y -c conda-forge easydict
pip install pyyaml

# Install PyTorch Geometric
pip install torch-scatter -f https://pytorch-geometric.com/whl/torch-1.7.0+cu102.html
pip install torch-sparse -f https://pytorch-geometric.com/whl/torch-1.7.0+cu102.html
pip install torch-cluster -f https://pytorch-geometric.com/whl/torch-1.7.0+cu102.html
pip install torch-spline-conv -f https://pytorch-geometric.com/whl/torch-1.7.0+cu102.html
pip install torch-geometric==1.6.3

# Install Library
git clone https://github.com/DeepGraphLearning/ConfGF.git
cd ConfGF
python setup.py install

it also needs command line to train the model.

Thank you in advance

Because of the heavy amount of dependencies, it sounds like pythoncall would be your best bet.

Thank you, from the tutorial of PythonCall.jl, it seems there is no material for this kind of application, It would be helpful if anyone can share some successful experience?

It depends what you’re trying to achieve, but if you already have all that stuff installed into a Conda environment then you can do

ENV["JULIA_PYTHONCALL_EXE"] = "python"
using PythonCall
@py import confgf
...

That first line forces PythonCall to use Python from your own Conda environment.

No I have not install all the things, I was thinking there is conda in Julia package, can I install all the things with that conda? and use this library entirely in Julia. I want to train the model with my data in Julia and produce some results in Julia, in other words, I want to use this library without leaving Julia. Thank you very much for your help!

python -u script/train.py --config_path ./config/qm9_default.yml
python -u script/train.py --config_path ./config/drugs_default.yml
python -u script/train.py --config_path ./config/iso17_default.yml

It also needs command line to train the model like that

If I install all these in a python environment, it need to create a virtual environment (“confgf”)

So we just import this library from this virtual environment in Julia with PythonCall?

How about the command line trainning part?

I installed the packages , and did as following:

ENV["JULIA_PYTHONCAL_EXE"] = "/usr/local/Caskroom/miniconda/base/envs/confgf/bin/python"
using PythonCall
@py import confgf

but it raised that confgf module not found error, after I tried torch, pandas or other packages installed there, same error,
only re, os this kind of module is ok.

the following code showed that confgf is installed.

Installed /usr/local/Caskroom/miniconda/base/envs/confgf/lib/python3.8/site-packages/confgf-0.1.0-py3.8.egg
Processing dependencies for confgf==0.1.0
Finished processing dependencies for confgf==0.1.0

What could be the problem? Thank you!

There are two Ls in PythonCall :slight_smile:

Interestingly, They gave the SAME result, after adding L
import os is ok but import confgf or torch or other packages same Module not found Error.

I found you have a great package CondaPkg.jl, do I need to create the environment and install all things using your CondaPkg.jl?

I reboot all of them and now it works, thank you very much!!!

BTW, can it use python command line?
like

python -u script/train.py --config_path ./config/qm9_default.yml
python -u script/train.py --config_path ./config/drugs_default.yml
python -u script/train.py --config_path ./config/iso17_default.yml