# Is there a way to keep a Python 2 and Python 3 version of PyCall in two separate environments?

**URL:** <https://discourse.julialang.org/t/is-there-a-way-to-keep-a-python-2-and-python-3-version-of-pycall-in-two-separate-environments/19763>\
**Category:** General Usage\
**Created:** [January 17, 2019, 10:50pm UTC](https://discourse.julialang.org/t/is-there-a-way-to-keep-a-python-2-and-python-3-version-of-pycall-in-two-separate-environments/19763 "2019-01-17T22:50:10Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![marius311](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/marius311/32/3953_2.png) [@marius311](https://discourse.julialang.org/u/marius311)\
**Post date:** [January 17, 2019, 10:50pm UTC](https://discourse.julialang.org/t/is-there-a-way-to-keep-a-python-2-and-python-3-version-of-pycall-in-two-separate-environments/19763/1 "2019-01-17T22:50:10Z")

</div>

I’ve got separate projects which use Python 2 or Python 3 dependencies via PyCall. I want to avoid having to recompile everything whenever I need to switch Python versions, so I was hoping I could put a Python-2-built PyCall in one environment and a Python-3-built one in another.

I tried doing this but I think they share the same build so it doesn’t work. I also tried making the versions of PyCall be different (1.18.5 vs 1.18.4) hoping this makes it so things aren’t shared across environments, and now the version of Python is different in each environment, but every time I switch environments, I still get a precompile, which defeats the purpose.

Anyone have any ideas on if I can do this? (or any better ways to be switching between Python 2 and 3?) Thanks.

---

<div class="post-metadata">

**Author:** ![00vareladavid](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/00vareladavid/32/23521_2.png) [@00vareladavid](https://discourse.julialang.org/u/00vareladavid)\
**Post date:** [January 17, 2019, 11:34pm UTC](https://discourse.julialang.org/t/is-there-a-way-to-keep-a-python-2-and-python-3-version-of-pycall-in-two-separate-environments/19763/2 "2019-01-17T23:34:15Z")

</div>

I think using separate depots for each environment should work. You can do this by setting `LOAD_PATH` before for you switch environments.

---

<div class="post-metadata">

**Author:** ![tkf](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/tkf/32/17635_2.png) [@tkf](https://discourse.julialang.org/u/tkf)\
**Post date:** [January 18, 2019, 2:40am UTC](https://discourse.julialang.org/t/is-there-a-way-to-keep-a-python-2-and-python-3-version-of-pycall-in-two-separate-environments/19763/3 "2019-01-18T02:40:57Z")

</div>

Sadly this is not directly supported. It would require some help from Pkg.jl. See: [Package options · Issue #38 · JuliaLang/Juleps · GitHub](https://github.com/JuliaLang/Juleps/issues/38)

> [@00vareladavid](#):
>
> You can do this by setting `LOAD_PATH` before for you switch environments.

I think you need to set `DEPOT_PATH` (environment variable: `JULIA_DEPOT_PATH`) instead for isolating cache and PyCall setup.

---

<div class="post-metadata">

**Author:** ![00vareladavid](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/00vareladavid/32/23521_2.png) [@00vareladavid](https://discourse.julialang.org/u/00vareladavid)\
**Post date:** [January 18, 2019, 2:50am UTC](https://discourse.julialang.org/t/is-there-a-way-to-keep-a-python-2-and-python-3-version-of-pycall-in-two-separate-environments/19763/4 "2019-01-18T02:50:46Z")

</div>

Yes, thats right. I always mix those two variables 😅. It would indeed be nice to have a supported solution.

---

<div class="post-metadata">

**Author:** ![Balinus](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/balinus/32/243_2.png) [@Balinus](https://discourse.julialang.org/u/Balinus)\
**Post date:** [January 18, 2019, 8:52pm UTC](https://discourse.julialang.org/t/is-there-a-way-to-keep-a-python-2-and-python-3-version-of-pycall-in-two-separate-environments/19763/5 "2019-01-18T20:52:53Z")

</div>

How about building Julia 2 times and then each Julia version being linked to a specific Python distribution? Quite ugly, but I guess it would work.
