-
-
Notifications
You must be signed in to change notification settings - Fork 68
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conda support #18
Comments
The best workaround I have so far:
3a. Export JVM_OPTS so leiningen picks them up: JVM_OPTS="-Djava.library.path=$(python3-config --prefix)/lib" lein repl 3b. Update your shared library paths to similar to 3a. export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:"$(python3-config --prefix)/lib" 3c. Explicitly load the library: user> (require '[libpython-clj.python :as py])
nil
user> (require '[clojure.java.shell :as sh])
nil
user> (sh/sh "python3" "--version")
{:exit 0, :out "", :err "Python 3.6.9 :: Anaconda, Inc.\n"}
user> (System/getenv "PYTHONPATH")
nil
user> (System/getenv "PYTHONHOME")
"/home/chrisn/.conda/envs/envtest"
user> (py/initialize! :library-path (format "%s/lib/libpython3.6m.so"
(System/getenv "PYTHONHOME")))
:ok
user> (py/import-module "numpy")
<module 'numpy' from '/home/chrisn/.conda/envs/envtest/lib/python3.6/site-packages/numpy/__init__.py'> |
Conda now works out of the box in a test with no environment variable setting like above. Leaving issue open for a bit to get more feedback. |
I added support for conda-installing Clojupyter earlier this year. I'm not sure exactly what you'll be trying to accomplish, but some it might be useful. Even though I only use a few of the environment variables, I added access to all of them in env.clj. -Klaus. |
@klausharbo - Great to hear from you! What we needed to do was to find the python shared libraries when conda was activated and initialize them with enough information that we can load the same python modules and you would be able to were you to activate the environment and run the python REPL. I am having a bit of trouble full comprehending that file you linked to. These are variables that you expect to find in your environment when conda installs clojupyter I guess as part of the install process? |
I was probably too fast in posting - sorry for being obtuse. :-) I did struggle quite a bit in First off, I found the Conda Deep Dive video helpful in explaining the fundamental concepts. There's quite a bit of Conda documentation, but I have found it hard to understand - it simply doesn't always seem to address the questions I have. It may very well be because I don't really know Python and so the finer points are lost on me. My notes recapping some of the early slides in the video: Package
Channel
Environment
The obscure For that I suspect the key environment variable is In my setup right now (I recently switched to Miniconda since I don't need all things included in Anaconda):
where we have
but doing
means we get
|
It doesn't look like my last comment about |
Your perspective is correct; we are working with the runtime environment, not attempting to build a package. |
Next problem: :ok
libpython-clj.python> (def mxnet (import-module "mxnet"))
Execution error at libpython-clj.python.interpreter/check-error-throw (interpreter.clj:394).
Traceback (most recent call last):
File "/home/chrisn/.conda/envs/pyclj/lib/python3.6/site-packages/mxnet/__init__.py", line 24, in <module>
from .context import Context, current_context, cpu, gpu, cpu_pinned
File "/home/chrisn/.conda/envs/pyclj/lib/python3.6/site-packages/mxnet/context.py", line 24, in <module>
from .base import classproperty, with_metaclass, _MXClassPropertyMetaClass
File "/home/chrisn/.conda/envs/pyclj/lib/python3.6/site-packages/mxnet/base.py", line 213, in <module>
_LIB = _load_lib()
File "/home/chrisn/.conda/envs/pyclj/lib/python3.6/site-packages/mxnet/base.py", line 204, in _load_lib
lib = ctypes.CDLL(lib_path[0], ctypes.RTLD_LOCAL)
File "/home/chrisn/.conda/envs/pyclj/lib/python3.6/ctypes/__init__.py", line 348, in __init__
self._handle = _dlopen(self._name, mode)
OSError: libmkldnn.so.0: cannot open shared object file: No such file or directory |
Solved by using LD_LIBRARY_PATH in lein repl startup script. |
This (LD_LIBRARY_PATH) is as good as we can get: For a working pathway, use the conda docker container. |
We need help with this. It is possible, it is a matter of figuring out the changes that conda makes to the system and what env variables the conda python shim sets up.
This is very important for newcomer experience so if you know anyone who knows how conda works or want to spend some time working with conda and libpython-clj please jump right in.
The text was updated successfully, but these errors were encountered: