Comments (15)
Sorry you're still having trouble with this! The next major release should be out soon and after that I think we can start to prioritize some better tutorials and "getting started" documentation.
I notice that you're using 1.17-SNAPSHOT. That might be part of the problem. Try with 1.12, 1.13 or 1.16 and see if that helps
from libpython-clj.
We're still actively working on the API, please feel free to join the discussion, @PlumpMath! (https://clojurians.zulipchat.com/#narrow/stream/215609-libpython-clj-dev) I'm also learning to make games with Clojure/Script! :D
from libpython-clj.
The nugget of information here is:
[:java-library-path ["/run/opengl-driver/lib/libpython3.7m.so" "/run/opengl-driver-32/lib/libpython3.7m.so" "/usr/java/packages/lib/libpython3.7m.so" "/usr/lib64/libpython3.7m.so" "/lib64/libpython3.7m.so" "/lib/libpython3.7m.so" "/usr/lib/libpython3.7m.so"]]
my libpython3.7m.so file here "/run/current-system/sw/lib/libpython3.7m.so"
The trick would be to get the java-library-path to include the above directory when starting or for us to find whatever environment variable has that second pathway in it and attempt to read it and setup some state before loading python.
Closing for now but if we can keep going this direction it would be helpful.
from libpython-clj.
@PlumpMath - For conda specifically, I have a workaround:
#18
from libpython-clj.
I solved ^,.^ yesterday because you gave me hint. thanks.
hmm I dont like conda or venv;; because I don't like sandboxes for some reason. Like Alice in Wonderland. ^,.^;;;
from libpython-clj.
As of version 1.20+ you can use require-python
. The behavior isn't documented yet because I haven't written up the tests but experiment with this:
(ns myproject.core
(:require [libpython-clj.python :as python]
[libpython-clj.require :refer [require-python]))
(require-python '(math requests))
(math/sin 1)
(requests/get "https://www.google.com")
from libpython-clj.
Hi! Can you post some more details please? What system are you using, what version of libpython-clj, what repl, etc?
from libpython-clj.
Great, did you get it working? :D That's the most important thing!
from libpython-clj.
{:clojure.main/message
"Execution error (NullPointerException) at tech.jna.base/fn (base.clj:35).\nnull\n",
:clojure.main/triage
{:clojure.error/class java.lang.NullPointerException,
:clojure.error/line 35,
:clojure.error/symbol tech.jna.base/fn,
:clojure.error/source "base.clj",
:clojure.error/phase :execution},
:clojure.main/trace
{:via
[{:type clojure.lang.Compiler$CompilerException,
:message "Syntax error macroexpanding at (base.clj:34:7).",
:data
{:clojure.error/phase :execution,
:clojure.error/line 34,
:clojure.error/column 7,
:clojure.error/source "base.clj"},
:at [clojure.lang.Compiler$InvokeExpr eval "Compiler.java" 3707]}
{:type java.lang.NullPointerException,
:at [tech.jna.base$fn__15233 invokeStatic "base.clj" 35]}],
:trace
[[tech.jna.base$fn__15233 invokeStatic "base.clj" 35]
[tech.jna.base$fn__15233 invoke "base.clj" 34]
[clojure.lang.AFn applyToHelper "AFn.java" 154]
[clojure.lang.AFn applyTo "AFn.java" 144]
[clojure.lang.Compiler$InvokeExpr eval "Compiler.java" 3702]
[clojure.lang.Compiler$DefExpr eval "Compiler.java" 457]
[clojure.lang.Compiler eval "Compiler.java" 7182]
[clojure.lang.Compiler load "Compiler.java" 7636]
[clojure.lang.RT loadResourceScript "RT.java" 381]
[clojure.lang.RT loadResourceScript "RT.java" 372]
[clojure.lang.RT load "RT.java" 459]
[clojure.lang.RT load "RT.java" 424]
[clojure.core$load$fn__6839 invoke "core.clj" 6126]
[clojure.core$load invokeStatic "core.clj" 6125]
[clojure.core$load doInvoke "core.clj" 6109]
[clojure.lang.RestFn invoke "RestFn.java" 408]
[clojure.core$load_one invokeStatic "core.clj" 5908]
[clojure.core$load_one invoke "core.clj" 5903]
[clojure.core$load_lib$fn__6780 invoke "core.clj" 5948]
[clojure.core$load_lib invokeStatic "core.clj" 5947]
[clojure.core$load_lib doInvoke "core.clj" 5928]
[clojure.lang.RestFn applyTo "RestFn.java" 142]
[clojure.core$apply invokeStatic "core.clj" 667]
[clojure.core$load_libs invokeStatic "core.clj" 5985]
[clojure.core$load_libs doInvoke "core.clj" 5969]
[clojure.lang.RestFn applyTo "RestFn.java" 137]
[clojure.core$apply invokeStatic "core.clj" 667]
[clojure.core$require invokeStatic "core.clj" 6007]
[clojure.core$require doInvoke "core.clj" 6007]
[clojure.lang.RestFn invoke "RestFn.java" 421]
[tech.jna$eval14904$loading__6721__auto____14905 invoke "jna.clj" 1]
[tech.jna$eval14904 invokeStatic "jna.clj" 1]
[tech.jna$eval14904 invoke "jna.clj" 1]
[clojure.lang.Compiler eval "Compiler.java" 7177]
[clojure.lang.Compiler eval "Compiler.java" 7166]
[clojure.lang.Compiler load "Compiler.java" 7636]
[clojure.lang.RT loadResourceScript "RT.java" 381]
[clojure.lang.RT loadResourceScript "RT.java" 372]
[clojure.lang.RT load "RT.java" 459]
[clojure.lang.RT load "RT.java" 424]
[clojure.core$load$fn__6839 invoke "core.clj" 6126]
[clojure.core$load invokeStatic "core.clj" 6125]
[clojure.core$load doInvoke "core.clj" 6109]
[clojure.lang.RestFn invoke "RestFn.java" 408]
[clojure.core$load_one invokeStatic "core.clj" 5908]
[clojure.core$load_one invoke "core.clj" 5903]
[clojure.core$load_lib$fn__6780 invoke "core.clj" 5948]
[clojure.core$load_lib invokeStatic "core.clj" 5947]
[clojure.core$load_lib doInvoke "core.clj" 5928]
[clojure.lang.RestFn applyTo "RestFn.java" 142]
[clojure.core$apply invokeStatic "core.clj" 667]
[clojure.core$load_libs invokeStatic "core.clj" 5985]
[clojure.core$load_libs doInvoke "core.clj" 5969]
[clojure.lang.RestFn applyTo "RestFn.java" 137]
[clojure.core$apply invokeStatic "core.clj" 667]
[clojure.core$require invokeStatic "core.clj" 6007]
[clojure.core$require doInvoke "core.clj" 6007]
[clojure.lang.RestFn invoke "RestFn.java" 1289]
[tech.v2.datatype$eval14898$loading__6721__auto____14899
invoke
"datatype.clj"
1]
[tech.v2.datatype$eval14898 invokeStatic "datatype.clj" 1]
[tech.v2.datatype$eval14898 invoke "datatype.clj" 1]
[clojure.lang.Compiler eval "Compiler.java" 7177]
[clojure.lang.Compiler eval "Compiler.java" 7166]
[clojure.lang.Compiler load "Compiler.java" 7636]
[clojure.lang.RT loadResourceScript "RT.java" 381]
[clojure.lang.RT loadResourceScript "RT.java" 372]
[clojure.lang.RT load "RT.java" 459]
[clojure.lang.RT load "RT.java" 424]
[clojure.core$load$fn__6839 invoke "core.clj" 6126]
[clojure.core$load invokeStatic "core.clj" 6125]
[clojure.core$load doInvoke "core.clj" 6109]
[clojure.lang.RestFn invoke "RestFn.java" 408]
[clojure.core$load_one invokeStatic "core.clj" 5908]
[clojure.core$load_one invoke "core.clj" 5903]
[clojure.core$load_lib$fn__6780 invoke "core.clj" 5948]
[clojure.core$load_lib invokeStatic "core.clj" 5947]
[clojure.core$load_lib doInvoke "core.clj" 5928]
[clojure.lang.RestFn applyTo "RestFn.java" 142]
[clojure.core$apply invokeStatic "core.clj" 667]
[clojure.core$load_libs invokeStatic "core.clj" 5985]
[clojure.core$load_libs doInvoke "core.clj" 5969]
[clojure.lang.RestFn applyTo "RestFn.java" 137]
[clojure.core$apply invokeStatic "core.clj" 667]
[clojure.core$require invokeStatic "core.clj" 6007]
[clojure.core$require doInvoke "core.clj" 6007]
[clojure.lang.RestFn invoke "RestFn.java" 3894]
[libpython_clj.jna$eval14890$loading__6721__auto____14891
invoke
"jna.clj"
1]
[libpython_clj.jna$eval14890 invokeStatic "jna.clj" 1]
[libpython_clj.jna$eval14890 invoke "jna.clj" 1]
[clojure.lang.Compiler eval "Compiler.java" 7177]
[clojure.lang.Compiler eval "Compiler.java" 7166]
[clojure.lang.Compiler load "Compiler.java" 7636]
[clojure.lang.RT loadResourceScript "RT.java" 381]
[clojure.lang.RT loadResourceScript "RT.java" 372]
[clojure.lang.RT load "RT.java" 459]
[clojure.lang.RT load "RT.java" 424]
[clojure.core$load$fn__6839 invoke "core.clj" 6126]
[clojure.core$load invokeStatic "core.clj" 6125]
[clojure.core$load doInvoke "core.clj" 6109]
[clojure.lang.RestFn invoke "RestFn.java" 408]
[clojure.core$load_one invokeStatic "core.clj" 5908]
[clojure.core$load_one invoke "core.clj" 5903]
[clojure.core$load_lib$fn__6780 invoke "core.clj" 5948]
[clojure.core$load_lib invokeStatic "core.clj" 5947]
[clojure.core$load_lib doInvoke "core.clj" 5928]
[clojure.lang.RestFn applyTo "RestFn.java" 142]
[clojure.core$apply invokeStatic "core.clj" 667]
[clojure.core$load_libs invokeStatic "core.clj" 5985]
[clojure.core$load_libs doInvoke "core.clj" 5969]
[clojure.lang.RestFn applyTo "RestFn.java" 137]
[clojure.core$apply invokeStatic "core.clj" 667]
[clojure.core$require invokeStatic "core.clj" 6007]
[clojure.core$require doInvoke "core.clj" 6007]
[clojure.lang.RestFn invoke "RestFn.java" 805]
[libpython_clj.python.interop$eval14884$loading__6721__auto____14885
invoke
"interop.clj"
1]
[libpython_clj.python.interop$eval14884
invokeStatic
"interop.clj"
1]
[libpython_clj.python.interop$eval14884 invoke "interop.clj" 1]
[clojure.lang.Compiler eval "Compiler.java" 7177]
[clojure.lang.Compiler eval "Compiler.java" 7166]
[clojure.lang.Compiler load "Compiler.java" 7636]
[clojure.lang.RT loadResourceScript "RT.java" 381]
[clojure.lang.RT loadResourceScript "RT.java" 372]
[clojure.lang.RT load "RT.java" 459]
[clojure.lang.RT load "RT.java" 424]
[clojure.core$load$fn__6839 invoke "core.clj" 6126]
[clojure.core$load invokeStatic "core.clj" 6125]
[clojure.core$load doInvoke "core.clj" 6109]
[clojure.lang.RestFn invoke "RestFn.java" 408]
[clojure.core$load_one invokeStatic "core.clj" 5908]
[clojure.core$load_one invoke "core.clj" 5903]
[clojure.core$load_lib$fn__6780 invoke "core.clj" 5948]
[clojure.core$load_lib invokeStatic "core.clj" 5947]
[clojure.core$load_lib doInvoke "core.clj" 5928]
[clojure.lang.RestFn applyTo "RestFn.java" 142]
[clojure.core$apply invokeStatic "core.clj" 667]
[clojure.core$load_libs invokeStatic "core.clj" 5985]
[clojure.core$load_libs doInvoke "core.clj" 5969]
[clojure.lang.RestFn applyTo "RestFn.java" 137]
[clojure.core$apply invokeStatic "core.clj" 667]
[clojure.core$require invokeStatic "core.clj" 6007]
[clojure.core$require doInvoke "core.clj" 6007]
[clojure.lang.RestFn invoke "RestFn.java" 551]
[libpython_clj.python$eval14859$loading__6721__auto____14860
invoke
"python.clj"
1]
[libpython_clj.python$eval14859 invokeStatic "python.clj" 1]
[libpython_clj.python$eval14859 invoke "python.clj" 1]
[clojure.lang.Compiler eval "Compiler.java" 7177]
[clojure.lang.Compiler eval "Compiler.java" 7166]
[clojure.lang.Compiler load "Compiler.java" 7636]
[clojure.lang.RT loadResourceScript "RT.java" 381]
[clojure.lang.RT loadResourceScript "RT.java" 372]
[clojure.lang.RT load "RT.java" 459]
[clojure.lang.RT load "RT.java" 424]
[clojure.core$load$fn__6839 invoke "core.clj" 6126]
[clojure.core$load invokeStatic "core.clj" 6125]
[clojure.core$load doInvoke "core.clj" 6109]
[clojure.lang.RestFn invoke "RestFn.java" 408]
[clojure.core$load_one invokeStatic "core.clj" 5908]
[clojure.core$load_one invoke "core.clj" 5903]
[clojure.core$load_lib$fn__6780 invoke "core.clj" 5948]
[clojure.core$load_lib invokeStatic "core.clj" 5947]
[clojure.core$load_lib doInvoke "core.clj" 5928]
[clojure.lang.RestFn applyTo "RestFn.java" 142]
[clojure.core$apply invokeStatic "core.clj" 667]
[clojure.core$load_libs invokeStatic "core.clj" 5985]
[clojure.core$load_libs doInvoke "core.clj" 5969]
[clojure.lang.RestFn applyTo "RestFn.java" 137]
[clojure.core$apply invokeStatic "core.clj" 667]
[clojure.core$require invokeStatic "core.clj" 6007]
[clojure.core$require doInvoke "core.clj" 6007]
[clojure.lang.RestFn invoke "RestFn.java" 2088]
[user$eval138$loading__6721__auto____139 invoke "cljIMPORT.clj" 1]
[user$eval138 invokeStatic "cljIMPORT.clj" 1]
[user$eval138 invoke "cljIMPORT.clj" 1]
[clojure.lang.Compiler eval "Compiler.java" 7177]
[clojure.lang.Compiler eval "Compiler.java" 7166]
[clojure.lang.Compiler load "Compiler.java" 7636]
[clojure.lang.Compiler loadFile "Compiler.java" 7574]
[clojure.main$load_script invokeStatic "main.clj" 475]
[clojure.main$script_opt invokeStatic "main.clj" 535]
[clojure.main$script_opt invoke "main.clj" 530]
[clojure.main$main invokeStatic "main.clj" 664]
[clojure.main$main doInvoke "main.clj" 616]
[clojure.lang.RestFn applyTo "RestFn.java" 137]
[clojure.lang.Var applyTo "Var.java" 705]
[clojure.main main "main.java" 40]],
:phase :execution}}
from libpython-clj.
hmmm g,.g
java -jar standalone can execute~*
but can't require
libpython-clj/target]$ java -jar libpython-clj-1.17-SNAPSHOT-standalone.jar
Clojure 1.10.1
user=> (require '[libpython-clj :as py])
Execution error (FileNotFoundException) at user/eval1 (REPL:1).
Could not locate libpython_clj__init.class, libpython_clj.clj or libpython_clj.cljc on classpath. Please check that namespaces with dashes use underscores in the Clojure file name.
user=>
I'm linux master (git clone ~)
It worked a few days ago, but... now can't.
Thanks.
from libpython-clj.
hmmm. So running the jar standalone works but attempting to just start a repl and do a require of the main namespace into the user namespace is giving you that error?
from libpython-clj.
The module will now be loaded.
next problem.
clojure.lang.ExceptionInfo: Failed to load library
{:libname "python3.7m", :paths [[:system ["python3.7m"]] [:java-library-path ["/run/opengl-driver/lib/libpython3.7m.so" "/run/opengl-driver-32/lib/libpython3.7m.so" "/usr/java/packages/lib/libpython3.7m.so" "/usr/lib64/libpython3.7m.so" "/lib64/libpython3.7m.so" "/lib/libpython3.7m.so" "/usr/lib/libpython3.7m.so"]]]}
at tech.jna.base$do_load_library.invokeStatic (base.clj:158)
tech.jna.base$do_load_library.invoke (base.clj:123)
tech.jna.base$load_library.invokeStatic (base.clj:178)
tech.jna.base$load_library.invoke (base.clj:174)
tech.jna.base$do_find_function.invokeStatic (base.clj:213)
tech.jna.base$do_find_function.invoke (base.clj:212)
tech.jna.base$find_function.invokeStatic (base.clj:218)
tech.jna.base$find_function.invoke (base.clj:216)
libpython_clj.jna.interpreter$PySys_SetArgv.invokeStatic (interpreter.clj:66)
libpython_clj.jna.interpreter$PySys_SetArgv.invoke (interpreter.clj:66)
clojure.lang.Var.invoke (Var.java:388)
libpython_clj.python.interpreter$initialize_BANG_$fn__36661.invoke (interpreter.clj:263)
clojure.lang.AFn.applyToHelper (AFn.java:152)
clojure.lang.AFn.applyTo (AFn.java:144)
clojure.core$apply.invokeStatic (core.clj:665)
clojure.core$with_bindings_STAR_.invokeStatic (core.clj:1973)
clojure.core$with_bindings_STAR_.doInvoke (core.clj:1973)
clojure.lang.RestFn.invoke (RestFn.java:425)
libpython_clj.python.interpreter$initialize_BANG_.invokeStatic (interpreter.clj:262)
libpython_clj.python.interpreter$initialize_BANG_.doInvoke (interpreter.clj:249)
clojure.lang.RestFn.invoke (RestFn.java:421)
libpython_clj.python$initialize_BANG_.invokeStatic (python.clj:228)
libpython_clj.python$initialize_BANG_.doInvoke (python.clj:220)
clojure.lang.RestFn.invoke (RestFn.java:397)
new_to_clojure$eval43261.invokeStatic (cljIMPORT.clj:69)
new_to_clojure$eval43261.invoke (cljIMPORT.clj:69)
clojure.lang.Compiler.eval (Compiler.java:7177)
clojure.lang.Compiler.eval (Compiler.java:7132)
clojure.core$eval.invokeStatic (core.clj:3214)
clojure.core$eval.invoke (core.clj:3210)
nrepl.middleware.interruptible_eval$evaluate$fn__14558.invoke (interruptible_eval.clj:112)
clojure.main$repl$read_eval_print__9086$fn__9089.invoke (main.clj:437)
clojure.main$repl$read_eval_print__9086.invoke (main.clj:437)
clojure.main$repl$fn__9095.invoke (main.clj:458)
clojure.main$repl.invokeStatic (main.clj:458)
clojure.main$repl.doInvoke (main.clj:368)
clojure.lang.RestFn.invoke (RestFn.java:1523)
nrepl.middleware.interruptible_eval$evaluate.invokeStatic (interruptible_eval.clj:105)
nrepl.middleware.interruptible_eval$evaluate.invoke (interruptible_eval.clj:74)
nrepl.middleware.interruptible_eval$interruptible_eval$fn__14582$fn__14586.invoke (interruptible_eval.clj:174)
clojure.lang.AFn.run (AFn.java:22)
nrepl.middleware.session$session_exec$main_loop__14686$fn__14690.invoke (session.clj:197)
nrepl.middleware.session$session_exec$main_loop__14686.invoke (session.clj:196)
clojure.lang.AFn.run (AFn.java:22)
java.lang.Thread.run (Thread.java:834)
wrong when you do (py/initialize!).
and my libpython3.7m.so file here
"/run/current-system/sw/lib/libpython3.7m.so"
and I change code to 3.6m to 3.7m (libpython-clj/src/libpython_clj/jna/base.clj)
(def ^:dynamic python-library "python3.7m")
;; (def ^:dynamic python-library "python3.6m")
;; (def ^:dynamic python-library-names ["python3.7m" "python3.6m"])
(def ^:dynamic python-library-names ["python3.7m"])
good day~* :) thanks!
from libpython-clj.
Anyway, I was lucky to find this project a few days before your announcement of clojure 2019.
I just wanted to handle Python directly from Clojure. I was lucky to find this project. Thank you for making it.
I'm working on 3D related development company job work is clojure and clojurescript and unity3d blender webgl 3d... Onz... I hate ai & ml... cause dont know.
Unfortunately, I can't use this good module freely because I can't English.
But with your help... so Finally, I started doing example code yesterday.
I got a strange question.
The Python module import and Python object usage is a little strange...
In particular, i haven't found the part where we can convert Pyobject. i will find out by watching the blog posts and videos, right?
.
Looking at the document is really a lot of trouble. I just found this on github. hahaha. I'm joking. @.@
Anyway, I'll going to learn linear algebra with this next year... Again, thank you very much for making it.
from libpython-clj.
Having the same problem going to check java path
from libpython-clj.
Not sure what the problem was but for any other noobs, I was having
"Could not locate libpython_clj__init.class, libpython_clj.clj or libpython_clj.cljc on classpath. Please check that namespaces with dashes use underscores in the Clojure file name."
fixed using:
(ns annoying
(:require [libpython-clj2.python :as py]))
(py/initialize! :python-executable "/usr/bin/python3.9"
:library-path "/usr/lib/python3.9")
(require '[libpython-clj2.require :refer [require-python]])
(require-python '[numpy :as np])
From emacs C-c C-k complie works
from libpython-clj.
Related Issues (20)
- Cannot run the example in the tutorial in Cider with JDK 17 HOT 8
- process hanging in embeded mode on exception HOT 2
- from-import does not support "string"
- newbie: I get: `dir already refers to: #'clojure.repl/dir in namespace: user` HOT 2
- Newbie: Lein Clojure Windows Anaconda VSCode Cava REPL Returns (NoClassDefFoundError) HOT 5
- Create Python Module then Import Module and Call Function Inside Clojure? HOT 4
- Fix ubuntu version in dockerfiles HOT 6
- Consider releasing returned values from instance fns
- JDK-20 support HOT 3
- builtins/eval throws 'frame does not exist' HOT 2
- Unable to require libraries from within docker using conda HOT 6
- Failed to find a valid python library on MS-Windows with the official python distributions
- Extend CI coverage to all the mainstream architectures
- require-python missing functions with annotation HOT 3
- Make polyglot development easier by allow require-python to be path-informed HOT 1
- Data transformation pipelines? HOT 1
- NSWindow main thread error when trying to setup Gymnasium (openapi gym) HOT 5
- JVM crashes when requiring `libpython-clj2.require` on 64bit Raspberry Pi 4 HOT 1
- error of unhashable type HOT 15
- Ways to reduce probability of memory leaks? HOT 2
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from libpython-clj.