JuliaPy / PyCall.jl

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

the ENV["PYTHON"]="path/to/python.exe" not work for python3.12.0 #1060

Closed nil-is-lin closed 8 months ago

nil-is-lin commented 8 months ago

I have upgrade the python to python 3.12.0. However, it can't find the package "matplotlib" install by pip, which works well for the old version of python(3.11.3). It should be the problem for new python version, I guess.

there is no error in the process "set ENV, build PyCall". It just cant change to the system-wide python.

stevengj commented 8 months ago

Can you show exactly what you did?

You should

  1. Start a fresh Julia session
  2. Set your ENV["PYTHON"] appropriately
  3. run using PyCall and check that PyCall.python is the desired python
  4. try pyimport("matplotlib") and see whether it succeeds
nil-is-lin commented 8 months ago

I believe the following screenshot can illustrate my problem. image

julia> using PyCall

julia> PyCall.python "C:\Users\nil_l\.julia\conda\3\x86_64\python.exe"

julia> ENV["PYTHON"] "D:\Python\Python312\python.exe"

(@v1.9) pkg> build PyCall Building Conda ─→ C:\Users\nil_l\.julia\scratchspaces\44cfe95a-1eb2-52ea-b672-e2afdf69b78f\8c86e48c0db1564a1d49548d3515ced5d604c408\build.log Building PyCall → C:\Users\nil_l\.julia\scratchspaces\44cfe95a-1eb2-52ea-b672-e2afdf69b78f\43d304ac6f0354755f1d60730ece8c499980f7ba\build.log

julia> PyCall.python "C:\Users\nil_l\.julia\conda\3\x86_64\python.exe"

stevengj commented 8 months ago

You need to start a new session after building PyCall, if PyCall has already been loaded. That's why step 1 in my comment above was "Start a fresh Julia session".

It would also be helpful to see the contents of the build.log file for PyCall.

nil-is-lin commented 8 months ago

You are right. I used the wrong process, every time I used PyCall to see if it changed, and then built again, so it didn't work.