I am trying to run a Julia script from python. I have Julia 1.6.4 installed (also tried 1.7.3) and installed pip install julia
from Pycharm’s terminal in the virtual environment. When importing julia and then running julia.install()
I get the following error message:
I use Pycharm with a virtual environment with Python 3.9.7 for my project. However, I have also tried different python versions in different virtual environments or by using the base python installed. All give the same error.
Also, ~/.julia/packages/PyCall/*/deps/build.log does not exist for me.
[ Info: Trying to import PyCall... Fatal Python error: init_import_size: Failed to import the site module Python runtime state: initialized Traceback (most recent call last): File "C:Program FilesWindowsAppsPythonSoftwareFoundation.Python.3.9_3.9.3568.0_x64__qbz5n2kfra8p0libsite.py", line 73, in <module> import os File "C:Program FilesWindowsAppsPythonSoftwareFoundation.Python.3.9_3.9.3568.0_x64__qbz5n2kfra8p0libos.py", line 29, in <module> from _collections_abc import _check_methods File "C:Program FilesWindowsAppsPythonSoftwareFoundation.Python.3.9_3.9.3568.0_x64__qbz5n2kfra8p0lib_collections_abc.py", line 12, in <module> GenericAlias = type(list[int]) TypeError: 'type' object is not subscriptable Traceback (most recent call last): File "<input>", line 1, in <module> File "C:Users<user>PycharmProjects<project>venvlibsite-packagesjuliatools.py", line 118, in install raise PyCallInstallError("Installing", output) julia.tools.PyCallInstallError: Installing PyCall failed. ** Important information from Julia may be printed before Python's Traceback ** Some useful information may also be stored in the build log file `~/.julia/packages/PyCall/*/deps/build.log`.```
Advertisement
Answer
- Julia needs to have PyCall installed
- PyCall in Julia needs to be configured to use the same Python that you are using to call Julia from
For more information see this post: I have a high-performant function written in Julia, how can I use it from Python?