# How to install Python packages for PyCall?

**URL:** <https://discourse.julialang.org/t/how-to-install-python-packages-for-pycall/64560>\
**Category:** General Usage\
**Tags:** question\
**Created:** [July 13, 2021, 12:15pm UTC](https://discourse.julialang.org/t/how-to-install-python-packages-for-pycall/64560 "2021-07-13T12:15:48Z")\
**Posts on this page:** 11\
**Page:** 1

<div class="post-metadata">

**Author:** ![abcde](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/abcde/32/16180_2.png) [@abcde](https://discourse.julialang.org/u/abcde)\
**Post date:** [July 13, 2021, 12:15pm UTC](https://discourse.julialang.org/t/how-to-install-python-packages-for-pycall/64560/1 "2021-07-13T12:15:49Z")

</div>

How to install Python PKG in Julia using PyCall?  
For example,[https://github.com/LucasBoTang/Optimal\_Classification\_Trees](https://github.com/LucasBoTang/Optimal_Classification_Trees)，  
How can it be used in Julia?  
Thank you very much!

---

<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:** [July 13, 2021, 12:18pm UTC](https://discourse.julialang.org/t/how-to-install-python-packages-for-pycall/64560/2 "2021-07-13T12:18:46Z")

</div>

> [@abcde](#):
>
> How to install Python PKG in Julia using PyCall?

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](https://github.com/JuliaPy/PyCall.jl#specifying-the-python-version)

---

<div class="post-metadata">

**Author:** ![abcde](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/abcde/32/16180_2.png) [@abcde](https://discourse.julialang.org/u/abcde)\
**Post date:** [July 14, 2021, 12:12pm UTC](https://discourse.julialang.org/t/how-to-install-python-packages-for-pycall/64560/3 "2021-07-14T12:12:04Z")

</div>

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

---

<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:** [July 14, 2021, 12:18pm UTC](https://discourse.julialang.org/t/how-to-install-python-packages-for-pycall/64560/4 "2021-07-14T12:18:06Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![abcde](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/abcde/32/16180_2.png) [@abcde](https://discourse.julialang.org/u/abcde)\
**Post date:** [July 14, 2021, 12:27pm UTC](https://discourse.julialang.org/t/how-to-install-python-packages-for-pycall/64560/5 "2021-07-14T12:27:32Z")

</div>

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

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!

---

<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:** [July 14, 2021, 12:36pm UTC](https://discourse.julialang.org/t/how-to-install-python-packages-for-pycall/64560/6 "2021-07-14T12:36:57Z")

</div>

> [@abcde](#):
>
> Then what do I need to do to download Python PKG in Julia?

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.

---

<div class="post-metadata">

**Author:** ![abcde](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/abcde/32/16180_2.png) [@abcde](https://discourse.julialang.org/u/abcde)\
**Post date:** [July 14, 2021, 12:41pm UTC](https://discourse.julialang.org/t/how-to-install-python-packages-for-pycall/64560/7 "2021-07-14T12:41:58Z")

</div>

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！

---

<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:** [July 14, 2021, 12:50pm UTC](https://discourse.julialang.org/t/how-to-install-python-packages-for-pycall/64560/8 "2021-07-14T12:50:08Z")

</div>

> [@abcde](#):
>
> One more question is, are these PKGs of Python installed in Julia’s REPL?  
> Or do you install it manually by some other method?

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](https://github.com/JuliaPy/Conda.jl#conda-and-pip). 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.)

---

<div class="post-metadata">

**Author:** ![abcde](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/abcde/32/16180_2.png) [@abcde](https://discourse.julialang.org/u/abcde)\
**Post date:** [July 14, 2021, 12:57pm UTC](https://discourse.julialang.org/t/how-to-install-python-packages-for-pycall/64560/10 "2021-07-14T12:57:06Z")

</div>

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](http://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！

---

<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:** [July 14, 2021, 1:01pm UTC](https://discourse.julialang.org/t/how-to-install-python-packages-for-pycall/64560/11 "2021-07-14T13:01:27Z")

</div>

> [@abcde](#):
>
> 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:

```julia
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.

---

<div class="post-metadata">

**Author:** ![abcde](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/abcde/32/16180_2.png) [@abcde](https://discourse.julialang.org/u/abcde)\
**Post date:** [July 14, 2021, 1:02pm UTC](https://discourse.julialang.org/t/how-to-install-python-packages-for-pycall/64560/12 "2021-07-14T13:02:22Z")

</div>

Thank you for your answer!
