# PyCall pointing to correct venv but not picking up the correct path (likely related to .pythonstartup)

**URL:** <https://discourse.julialang.org/t/pycall-pointing-to-correct-venv-but-not-picking-up-the-correct-path-likely-related-to-pythonstartup/122922>\
**Category:** General Usage\
**Tags:** pycall, python, path\
**Created:** [November 22, 2024, 3:01am UTC](https://discourse.julialang.org/t/pycall-pointing-to-correct-venv-but-not-picking-up-the-correct-path-likely-related-to-pythonstartup/122922 "2024-11-22T03:01:14Z")\
**Posts on this page:** 1\
**Showing post:** 2

<div class="post-metadata">

**Author:** ![eldee](https://avatars.discourse-cdn.com/v4/letter/e/b5a626/32.png) [@eldee](https://discourse.julialang.org/u/eldee)\
**Post date:** [November 25, 2024, 6:27pm UTC](https://discourse.julialang.org/t/pycall-pointing-to-correct-venv-but-not-picking-up-the-correct-path-likely-related-to-pythonstartup/122922/2 "2024-11-25T18:27:21Z")

</div>

Hi Colin,

> [@colintbowers](#):
>
> Is there any way to get it to run `.pythonstartup`?

Maybe this is not the approach you’re after, but you could just use `@pyinclude(ENV["PYTHONSTARTUP"])`.

* * *

For a Python startup file containing

```Python
import sys
sys.path = ["FromStartup"]

```

(the path of which is contained in the environment variable `PYTHONSTARTUP`), I get

```julia
using PyCall
sys = pyimport("sys")
println(length(sys.path)) # 6, i.e. not just ["FromStartup"]
@pyinclude(ENV["PYTHONSTARTUP"])
println(sys.path) # ["FromStartup"]

```

* * *

Nowadays PythonCall.jl seems to be [preferred](https://discourse.julialang.org/t/how-to-choose-between-pycall-jl-and-pythoncall-jl/100214) over PyCall.jl. As far as I can tell there is no equivalent to `@pyinclude`, but you could use something like

```julia
# (After restarting)
using PythonCall
sys = pyimport("sys")
println(length(sys.path)) # 6
# So also PythonCall.jl does not run the startup file automatically
@pyexec (path=ENV["PYTHONSTARTUP"]) =>
    """
    with open(path) as f:
       exec(f.read())
    """
println(sys.path) # ['FromStartup']

```

---

_[View the full topic](https://discourse.julialang.org/t/pycall-pointing-to-correct-venv-but-not-picking-up-the-correct-path-likely-related-to-pythonstartup/122922)._
