JuliaPy / PyCall.jl

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

Feature Request because of the issue(difficult to add a custom Python version, and packages) #947

Open MalteBoehm opened 2 years ago

MalteBoehm commented 2 years ago

Hey there currently i´m building a docker julia template i want to share with everyone. https://github.com/MalteBoehm/julia_docker-compose_template

The current issue is that when i install my own python environment, PyCall adds a HOMEPYTHON Env variable which causes a Fatal Python error and its not possible to unset those variables.

See here: https://github.com/MalteBoehm/julia_docker-compose_template/blob/main/Dockerfile

My suggestion is to add parameters to PyCall from the very beginning, like Python Version and if should install packages via

environment.yml -> conda env create environment.yml conda activate yourEnviroment

This is the Error i get: `Fatal Python error: init_fs_encoding: failed to get the Python codec of the filesystem encoding

Python runtime state: core initialized

ModuleNotFoundError: No module named 'encodings'

Current thread 0x00007f43d5ea5b48 (most recent call first): Current thread 0x00007f84a9e9bb48 (most recent call first):

Python path configuration: PYTHONHOME = '/root/.pyenv/versions/3.7.8:/root/.pyenv/versions/3.7.8' PYTHONPATH = (not set) program name = '/root/.pyenv/versions/3.7.8/bin/python3' isolated = 0 environment = 1 user site = 1 import site = 1 sys._base_executable = '/root/.pyenv/versions/3.7.8/bin/python3' sys.base_prefix = '/root/.pyenv/versions/3.7.8' sys.base_exec_prefix = '/root/.pyenv/versions/3.7.8' sys.platlibdir = 'lib' sys.executable = '/root/.pyenv/versions/3.7.8/bin/python3' sys.prefix = '/root/.pyenv/versions/3.7.8' sys.exec_prefix = '/root/.pyenv/versions/3.7.8' sys.path = [ '/root/.pyenv/versions/3.7.8/lib/python39.zip', '/root/.pyenv/versions/3.7.8/lib/python3.9', '/root/.pyenv/versions/3.7.8/lib/python3.9/lib-dynload', ] Fatal Python error: init_fs_encoding: failed to get the Python codec of the filesystem encoding Python runtime state: core initialized ModuleNotFoundError: No module named 'encodings'` Thanks for your help