Encountered the following error when I setup clj-python in virtual environment.
In order to fix the error, there are two steps which I did but the errors still exist.
to specify ":python-executable" and ":library-path" with "py/initialize!" (please see the source "core.clj:
If I did symbolic-linking in the virtualenv's lib "~/.venv/ml/lib/libpython3.7m.dylib" directory, "lein repl" cannot be started.
e.g ln -s /usr/local/Cellar/python/3.7.7/Frameworks/Python.framework/Versions/3.7/lib/libpython3.7m.dylib
Please feel free to comment.
update on 24 May 2020
"lein repl" can be started when revoke ":python-executable" and ":python-executable" to local dictionaries.
(ns my-stuff.core
(:require [libpython-clj.python :as py]))
(py/initialize! :python-executable "/usr/local/Cellar/python/3.7.7/Frameworks/Python.framework/Versions/3.7/bin/python3.7"
:library-path "/usr/local/Cellar/python/3.7.7/Frameworks/Python.framework/Versions/3.7/lib/libpython3.7m.dylib")
(require '[libpython-clj.require :refer [require-python]])
Error
my-stuff.core=> May 23, 2020 6:39:35 PM clojure.tools.logging$eval505$fn__508 invoke
INFO: Executing python initialize with options:{:python-executable "/Users/nelson/.venv/ml/bin/python", :program-name nil, :python-home nil, :library-path "/usr/local/Cellar/python/3.7.7/Frameworks/Python.framework/Versions/3.7/lib/libpython3.7m.dylib"}
May 23, 2020 6:39:35 PM clojure.tools.logging$eval505$fn__508 invoke
INFO: Detecting startup-info for Python executable: /Users/nelson/.venv/ml/bin/python
May 23, 2020 6:39:35 PM clojure.tools.logging$eval505$fn__508 invoke
INFO: Startup info detected:
{:lib-version "3.7",
:java-library-path-addendum "/Users/nelson/.venv/ml/lib",
:exec-prefix "/Users/nelson/.venv/ml",
:executable "/Users/nelson/.venv/ml/bin/python",
:libnames
("/usr/local/Cellar/python/3.7.7/Frameworks/Python.framework/Versions/3.7/lib/libpython3.7m.dylib"
"python3.7"),
:prefix "/Users/nelson/.venv/ml",
:base-prefix
"/usr/local/opt/python/bin/../Frameworks/Python.framework/Versions/3.7",
:base-exec-prefix
"/usr/local/opt/python/bin/../Frameworks/Python.framework/Versions/3.7",
:python-home "/Users/nelson/.venv/ml",
:version [3 7 7],
:platform "darwin"}
May 23, 2020 6:39:35 PM clojure.tools.logging$eval505$fn__508 invoke
INFO: Trying python library names ["/usr/local/Cellar/python/3.7.7/Frameworks/Python.framework/Versions/3.7/lib/libpython3.7m.dylib" "/usr/local/Cellar/python/3.7.7/Frameworks/Python.framework/Versions/3.7/lib/libpython3.7m.dylib" "python3.7" "python3.7m" "python3.6m"]
May 23, 2020 6:39:35 PM clojure.tools.logging$eval505$fn__508 invoke
INFO: Setting java library path: /Users/nelson/.venv/ml/lib:/Users/nelson/Library/Java/Extensions:/Library/Java/Extensions:/Network/Library/Java/Extensions:/System/Library/Java/Extensions:/usr/lib/java:.
May 23, 2020 6:39:35 PM clojure.tools.logging$eval505$fn__508 invoke
INFO: Reference thread starting
May 23, 2020 6:39:35 PM clojure.tools.logging$eval505$fn__508 invoke
INFO: Library /usr/local/Cellar/python/3.7.7/Frameworks/Python.framework/Versions/3.7/lib/libpython3.7m.dylib found at [:system "/usr/local/Cellar/python/3.7.7/Frameworks/Python.framework/Versions/3.7/lib/libpython3.7m.dylib"]
Fatal Python error: initfsencoding: unable to load the file system codec
ModuleNotFoundError: No module named 'encodings'
Current thread 0x0000700008986000 (most recent call first):
Subprocess failed (exit code: 134)
project.clj
(defproject my-stuff "0.1.0-SNAPSHOT"
:description "FIXME: write description"
:url "http://example.com/FIXME"
:license {:name "EPL-2.0 OR GPL-2.0-or-later WITH Classpath-exception-2.0"
:url "https://www.eclipse.org/legal/epl-2.0/"}
:dependencies [[org.clojure/clojure "1.10.1"]
[clj-python/libpython-clj "1.44"]]
:main ^:skip-aot my-stuff.core
:target-path "target/%s"
:profiles {:uberjar {:aot :all}})
core.clj
(ns my-stuff.core
(:require [libpython-clj.python :as py]
[libpython-clj.jna.base]))
(py/initialize! :python-executable (str (System/getenv "HOME") "/.venv/ml/bin/python")
:library-path (str "/usr/local/Cellar/python/3.7.7/Frameworks/Python.framework/Versions/3.7/lib/libpython3.7m.dylib"))