-
Notifications
You must be signed in to change notification settings - Fork 20
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
ImportError: cannot import name '_hy_macros' #15
Comments
Hy must have changed. PRs accepted! :) Thanks for reporting. |
I have same error, pls help |
A potential solution, in the meantime, is to use Hy version 0.15.0. It's worth noting that this is the only way to get Hy running on Python 3.7 in Jupyter.
|
@HaiNguyen007 Have you had difficulty with defining Macros in my proposed workaround? I seem to not be able to...
It seems to work in the regular Hy REPL, though...
|
I've just tried installing it and it failed with the same error. Unfortunately I don't have nearly enough knowledge to fix this but it would be awesome if this kernel actually worked, since this is the only maintained kernel for Hy! |
I digged around and modified the code that loads the macros to reflect the newest changes. Unfortunately there are other problems that prevent any code from running which I'll try to investigate but looks like they are inherent on how the calysto_hy's kernel executes code. |
I've modified the kernel yet again and now it runs! |
@Karrq, your fork works for me! Time for a PR soon? |
It wasn't working for me last time I tried... Can you tell me what did you try? |
I believe all I've done here is pip install the repo, python3 -m calysto_hy install --user, and jupyter console --kernel=calysto_hy |
@JeffCarpenter I meant to ask if you tried to use the code posted by @josiah14, as you can't declare new macros but you can run the kernel normally. |
To run the hy metakernel on Jupyter console and notebook I used following commands: $ pip3 install --user --force-reinstall ipython jupyter jupyterlab
$ pip3 install --user --force-reinstall metakernel ipyparallel
$ pip3 install --user --force-reinstall git+https://github.com/hylang/[email protected]
$ pip3 install --user --force-reinstall git+https://github.com/Karrq/calysto_hy.git
$ pip3 install --force-reinstall jupyter
$ python3 -m calysto_hy install --user
$ jupyter console --kernel calysto_hy
$ jupyter notebook --notebook-dir=.jupyter/ Versions:
|
@hastebrot I tried your exact instructions right now, and while the repl does boot up (in the case of Jupyter console) and you can type code in, and it highlights the syntax, it doesn't actually interpret any of the code entered by the end user. You can submit code, but no results are ever returned, and if you mess around long enough, you'll get this error message:
|
I also cannot import any Pip installed Python modules (like NumPy) in versions of Hy > 0.15 (so 0.15 is the latest version that I find actually usable). Also still unable to run my macros inside of Jupyter Console on any version of Hy (obviously I guess, since not much has changed on version 0.15, and I can't get 0.16 and 0.17 working in any meaningfully useful way). |
For others that come here, it appears that Hy and Calysto_Hy don't play nice with Conda/Anaconda created virtualenvs. I got everything except macros in the jupyter console working using |
Sad face. I like Lisp a lot, and have to write Python now, and want to show off Hy at the Atlanta Functional Programming Meetup, to show macros. And everybody loves Jupyter... |
for what it's worth, I got the console working following @hastebrot's comment, but I did also need |
Sorry for spamming this issue, but I believe I got it working now! |
I'm glad things seem to be working for most people. However, it's noteworthy that Macros now aren't working in either Jupyter Lab/Notebook or Jupyter Console. I've moved-up to using Hy 0.19.0, and I'm pleased at least to see that the basics are working, though. I figured this comment wouldn't be considered spamming the ticket since it's still open and there also hasn't been a ton of activity on it. |
Hy is pretty neat, but the lack of Jupyter stability causes me to recommend it to my more advanced engineers/engineering teams, but not so much to data scientists looking for a more convenient Python for data exploration. It would be really cool if Hy could serve that purpose in the future, though, as LISP was designed around "list processing", and most data science work is working with multidimensional list-like structures. |
Huh that's weird. I've installed everything from scratch with this simple
on a clean Python 3.8.0 virtualenv and your exact example is running fine. Can you confirm that you have the latest Calysto Hy? |
Also, this. That's precisely why I wanted to give this issue a shot. I'm quite busy atm, but I should soon start posting about and spreading some Hy and Calysto Hy awareness on my personal blog, targeting my DS friends. Glad to see more people interested in bringing Hy to Data Science! |
Oh I believe that Calysto Hy is doing great already! I think that it is working just as expected now. One thing that still bugs me though is the lack of image inlining. I wish I had more time to tackle #6, since I actually prefer working in Emacs rather than using the browser, most of the times. So I needed inlining in order to properly display images in Emacs. I tried looking into it but the code rabbit whole is just too deep for me right now. For now I resort to either accepting my fate and turning to Jupyter Lab in my browser or sticking to Emacs and simply saving the image to disk and displaying it in another buffer.
Yeah, if the latest changes haven't been pushed to PyPI yet then that might be it. Actually, I haven't even tried installing Calysto Hy from PyPI before because the README does not point to that option in the installation process. Maybe the README should be updated as well? |
I won't get time again to toy with this until Wednesday, so I'll check back in with you guys then and see what I can get working. |
FWIW, I'm having this issue with Hy 0.24 today. |
I also have the same issue with all the latest versions, using python 3.9.9: # requirements.txt
# ...
calysto-hy==0.1.1
hy==0.24.0
jedhy==1.0.0
jupyterlab==3.4.4
# ... # docker-compose.yml
# ...
jupyter-server:
build: .
command: >
/bin/bash -c '
python3 -m calysto_hy install &&
alembic upgrade head &&
jupyter lab --ip 0.0.0.0 --no-browser --allow-root
'
# ... Error: jupyter-server | Traceback (most recent call last):
jupyter-server | File "/usr/local/lib/python3.9/runpy.py", line 188, in _run_module_as_main
jupyter-server | mod_name, mod_spec, code = _get_module_details(mod_name, _Error)
jupyter-server | File "/usr/local/lib/python3.9/runpy.py", line 147, in _get_module_details
jupyter-server | return _get_module_details(pkg_main_name, error)
jupyter-server | File "/usr/local/lib/python3.9/runpy.py", line 111, in _get_module_details
jupyter-server | __import__(pkg_name)
jupyter-server | File "/usr/local/lib/python3.9/site-packages/calysto_hy/__init__.py", line 2, in <module>
jupyter-server | from .kernel import CalystoHy
jupyter-server | File "/usr/local/lib/python3.9/site-packages/calysto_hy/kernel.py", line 13, in <module>
jupyter-server | from hy.macros import _hy_macros, load_macros
jupyter-server | ImportError: cannot import name '_hy_macros' from 'hy.macros' (/usr/local/lib/python3.9/site-packages/hy/macros.py)
jupyter-server exited with code 1 |
@epgui This isn't even the last error. I tried commenting out that part of the import but modules have been renamed and code has changed. It seems that Hy had a major re-write of the internals. I tried mucking with it for an hour or so but I just don't know enough about what the various parts do and how MetaKernel works. I would love to use Hy but a lack of Jupyter support is a deal breaker. |
During the last step of the installation of calysto_hy, an error raised:
I searched in ~/apps/miniconda3/envs/hylang/lib/python3.6/site-packages/hy/macros.py, there isn't
_hy_macros
in this module.Environment:
Ubuntu 16.04.
The text was updated successfully, but these errors were encountered: