JuliaPy / PyCall.jl

Package to call Python functions from the Julia language
MIT License
1.47k stars 187 forks source link

Relative Path does not work with `ENV["PYTHON"]` #929

Closed roflmaostc closed 2 years ago

roflmaostc commented 2 years ago

Doing

julia> ENV["PYTHON"] = "../thorlabs/thorlabs_env/bin/python"
"../thorlabs/thorlabs_env/bin/python"

julia> Pkg.build("PyCall")
    Building Conda ─→ `~/.julia/scratchspaces/44cfe95a-1eb2-52ea-b672-e2afdf69b78f/299304989a5e6473d985212c28928899c74e9421/build.log`
    Building PyCall → `~/.julia/scratchspaces/44cfe95a-1eb2-52ea-b672-e2afdf69b78f/169bb8ea6b1b143c5cf57df6d34d022a7b60c6db/build.log`
Precompiling project...
  1 dependency successfully precompiled in 4 seconds (216 already precompiled)

results in:

cat ~/.julia/scratchspaces/44cfe95a-1eb2-52ea-b672-e2afdf69b78f/169bb8ea6b1b143c5cf57df6d34d022a7b60c6db/build.log                  [18-10-21 | 7:16:00]
Collecting package metadata (current_repodata.json): ...working... done
Solving environment: ...working... done

# All requested packages already installed.

┌ Info: No system-wide Python was found; got the following error:
│ Base.IOError("could not spawn setenv(`../thorlabs/thorlabs_env/bin/python -c

[................]

└ using the Python distribution in the Conda package
[ Info: Running `conda install -y numpy` in root environment
[ Info: PyCall is using /home/fxw/.julia/conda/3/bin/python (Python 3.7.6) at /home/fxw/.julia/conda/3/bin/python, libpython = /home/fxw/.julia/conda/3/lib/libpython3.7m.so.1.0
[ Info: /home/fxw/.julia/packages/PyCall/BD546/deps/deps.jl has been updated
[ Info: /home/fxw/.julia/prefs/PyCall has been updated

Setting a full path

julia> ENV["PYTHON"] = "/home/fxw/thorlabs/thorlabs_env/bin/python"
"/home/fxw/Documents/Uni/my_projects/Duke_Sensor_Array/thorlabs/thorlabs_env/bin/python"

julia> Pkg.build("PyCall")
    Building Conda ─→ `~/.julia/scratchspaces/44cfe95a-1eb2-52ea-b672-e2afdf69b78f/299304989a5e6473d985212c28928899c74e9421/build.log`
    Building PyCall → `~/.julia/scratchspaces/44cfe95a-1eb2-52ea-b672-e2afdf69b78f/169bb8ea6b1b143c5cf57df6d34d022a7b60c6db/build.log`
Precompiling project...
  1 dependency successfully precompiled in 4 seconds (216 already precompiled)

results in

cat ~/.julia/scratchspaces/44cfe95a-1eb2-52ea-b672-e2afdf69b78f/169bb8ea6b1b143c5cf57df6d34d022a7b60c6db/build.log                  [18-10-21 | 7:16:02]
[ Info: PyCall is using /home/fxw/thorlabs/thorlabs_env/bin/python (Python 3.9.7) at /home/fxw/Documents/Uni/my_projects/Duke_Sensor_Array/thorlabs/thorlabs_env/bin/python, libpython = /usr/lib/libpython3.9.so.1.0
[ Info: /home/fxw/.julia/packages/PyCall/BD546/deps/deps.jl has been updated
[ Info: /home/fxw/.julia/prefs/PyCall has been updated
stevengj commented 2 years ago

It's not supposed to work. Paths in environment variables essentially always need to be absolute paths.

roflmaostc commented 2 years ago

OK, good to know that.

I also opened issue so that other people can find it.