How to install Python packages for PyCall?

How to install Python PKG in Julia using PyCall?
For example,https://github.com/LucasBoTang/Optimal_Classification_Trees
How can it be used in Julia?
Thank you very much!

The same way you would install it in Python.

It depends on what Python installation your PyCall is configured to use, of course — you need to install the package for that Python. See GitHub - JuliaPy/PyCall.jl: Package to call Python functions from the Julia language

Do I need to download the latest version of Python and set it up later?thanks

If you want. Alternatively, PyCall downloads its Anaconda Python distribution by default (using the Conda.jl package) and installs that in ~/.julia/conda, so you could use that.

Sorry, I’m new in this field and I don’t seem to understand the operation you mentioned :pensive:

I have used ]add Conda and installed it successfully.
Then what do I need to do to download Python PKG in Julia?
Sorry to trouble you!
Thank you very much!

Do you know how to install Python packages if you are using Python? It’s the same—Julia is just using an ordinary Python installation. If you don’t understand how to use Python, you will first need to learn about that — there are lots of books and tutorials on Python out there, and lots of Python forums.

Thank you for your advice. One more question is, are these PKGs of Python installed in Julia’s REPL?
Or do you install it manually by some other method?
thanks!

Optionally. In the Julia REPL, you can install Anaconda Python packages in Julia’s Conda installation using Conda.add("somepackage") and you can also use pip to install Python packages. Or you can install Python packages in the traditional Python way without invoking Julia at all. (All Conda.add and Conda.pip do are to invoke Python tools, after all.)

Sorry to bother you again!
Error reported during installation, error is as follows:

ERROR: failed process: Process(setenv('C:\Users\dell\.julia\conda\3\Scripts\conda.exe' install -y Optimal_Classification_Trees,[“PATH=C:\Users\dell\.julia\conda\3\Library\bin;C:\Users\dell\.julia\conda\3\Library\bin;C:\WINDOWS\system32;C:\WINDOWS;C:\WINDOWS\system32;C:\WINDOWS\System32\Wbem;C:\windows\system32;C:\WINDOWS\System32\WindowsPowerShell\v1.0\;D:\GUROBI\win64\bin;D:\SCIP\SCIPOptSuite 6.0.2\bin;C:\Windows;C:\Windows\System32\wbem;C:\Windows\System32\OpenSSH;C:\Program Files (x86)\NVIDIA Corporation\PhysX\Common;C:\Program Files\NVIDIA Corporation\NVIDIA NvDLISR;D:\Atom;D:\Julia\Julia-1.2.0\bin;C:\Users\dell\.atom;C:\Users\dell\.julia;D:\Julia-client\atom-julia-client-master;;C:\WINDOWS\System32\OpenSSH\;C:\Users\dell\AppData\Local\Microsoft\WindowsApps;D:\julia\Julia-0.6.4\bin;D:\VScode\Microsoft VS Code\bin;D:\Atom\xin;%USERPROFILE%\AppData\Local\Microsoft\WindowsApps;”, “USERDOMAIN_ROAMINGPROFILE=DESKTOP-788S9K3”, “HOMEPATH=\Users\dell”, “PATHEXT=.COM;.EXE;.BAT;.CMD;.VBS;.VBE;.JS;.JSE;.WSF;.WSH;.MSC”, “NODE_ENV=production”, “SESSIONNAME=Console”, “SYSTEMROOT=C:\WINDOWS”, “APPDATA=C:\Users\dell\AppData\Roaming”, “PSMODULEPATH=C:\Program Files\WindowsPowerShell\Modules;C:\WINDOWS\system32\WindowsPowerShell\v1.0\Modules”, “COMMONPROGRAMW6432=C:\Program Files\Common Files” … “LOGONSERVER=\\DESKTOP-788S9K3”, “DRIVERDATA=C:\Windows\System32\Drivers\DriverData”, “CONDA_PREFIX=C:\Users\dell\.julia\conda\3”, “ATOM_HOME=D:\Julia\.atom”, “FPS_BROWSER_USER_PROFILE_STRING=Default”, “JULIA_LOAD_PATH=@;@v#.#;@stdlib”, “SYSTEMDRIVE=C:”, “FPS_BROWSER_APP_PROFILE_STRING=Internet Explorer”, “PROCESSOR_ARCHITECTURE=AMD64”, “OPENBLAS_MAIN_FREE=1”]), ProcessExited(1)) [1]

Why is that?thanks!

You didn’t quote the whole error message. At the very top there should have been a message that explains exactly what is going on:

PackagesNotFoundError: The following packages are not available from current channels:

  - optimal_classification_trees

That is, Optimal_Classification_Trees is not the name of an Anaconda Python package — the code you want may exist on github, but that doesn’t mean someone has packaged it.

These questions have nothing to do with Julia — you are going to have a pretty hard time using PyCall if you don’t understand Python, since PyCall just calls Python directly. You really need to learn Python first and learn how to download and install Python code. I would suggest asking on a Python forum how to install and use the package you want.

Thank you for your answer!