Skip to content
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

importmagic freezing Emacs startup #10145

Open
lukeorland opened this issue Jan 12, 2018 · 14 comments
Open

importmagic freezing Emacs startup #10145

lukeorland opened this issue Jan 12, 2018 · 14 comments

Comments

@lukeorland
Copy link

Description :octocat:

After started emacs, it gets frozen on the Spacemacs buffer. I can type <C-g> to get the initialization to finish.

I look at the *Messages* buffer and see the lines

[yas] Prepared just-in-time loading of snippets successfully.
Importmagic and/or epc not found. importmagic.el will not be working.
Quit

It appears that importmagic.el is looking for the importmagic PyPI package to be installed in the system Python environment. I use virtual environments and keep my system Python installation clean of external packages.

Reproduction guide 🪲

  • Start Emacs

Observed behaviour: 👀 💔

Frozen on startup.

Expected behaviour: ❤️ 😄

Not frozen on startup.

System Info 💻

  • OS: gnu/linux
  • Emacs: 25.3.1
  • Spacemacs: 0.300.0
  • Spacemacs branch: develop (rev. 86ff0eb)
  • Graphic display: t
  • Distribution: spacemacs
  • Editing style: vim
  • Completion: helm
  • Layers:
(python react javascript csv clojure dash deft docker emoji evernote github graphviz html ipython-notebook java pandoc python restclient scala shell-scripts search-engine semantic spotify sql tmux yaml helm auto-completion better-defaults emacs-lisp git markdown neotree org
        (shell :variables shell-default-shell 'multi-term shell-default-position 'right)
        spell-checking syntax-checking version-control)
  • System configuration features: XPM JPEG TIFF GIF PNG RSVG IMAGEMAGICK SOUND DBUS GCONF GSETTINGS NOTIFY ACL LIBSELINUX GNUTLS LIBXML2 FREETYPE M17N_FLT LIBOTF XFT ZLIB TOOLKIT_SCROLL_BARS GTK3 X11 MODULES XWIDGETS
@lukeorland
Copy link
Author

lukeorland commented Jan 12, 2018

I installed importmagic and epc in a pyenv environment that is backing one of the Python buffers that is opened on startup, and the messages changed to:

[yas] Prepared just-in-time loading of snippets successfully.
Quit
Shell native completion is disabled, using fallback
[importmagic] Indexed (/path/to/directory/containing/python/file/being/opened)
Parsing spacemacs (LL)...done

Startup still freezes after the
[yas] Prepared just-in-time loading of snippets successfully. line is displayed.

@lukeorland
Copy link
Author

I deleted all the Python buffers and restarted Emacs, and startup completed without freezing.

I opened a Python file and restarted Emacs, and the freezing happened.

@lukeorland
Copy link
Author

In the Python buffer, I typed , r f and got the message

epc:net-send: Process epc con 3 not running

@syl20bnr
Copy link
Owner

Can you try to call:

(require 'pyvenv)
(pyvenv-activate DIRECTORY)

In your dotspacemacs/user-config directory.

@anachronic
Copy link

@lukeorland by default, importmagic does not care about virtual environments at all. Instead, you should rely on external packages to manage that, such as virtualenvwrapper.el or pyvenv which are known to work with importmagic. If you really need to change the python interpreter manually, you can setq the importmagic-python-interpreter variable.

What is strange though, is that it's loading importmagic in the spacemacs buffer, which it should not do. I don't use spacemacs but if the issue persists, please feel free to report upstream.

@mgorfer
Copy link

mgorfer commented Nov 13, 2018

I had the same error message in Spacemacs:
Importmagic and/or epc not found. importmagic.el will not be working

I followed the steps in pythonic-emacs/anaconda-mode#295 and changed 127.0.0.1 to localhost in the anaconda-mode-host in anaconda-mode.el and now importmagic is working.


Please forget what I wrote above here. There is no connection.
When I start emacs normally and not directly on a .py file, I can access importmagic.
When I start emacs directly on a python file it cannot load.

@yssource
Copy link
Contributor

The problem happens to me also.
My python-backend is lsp.
Importmagic and/or epc not found. importmagic.el will not be working.

I use both pipenv and pyenv. But the importmagic does not care about virtual environments at all.

@albertmichaelj
Copy link

I'm having this issue as well. I am using the lsp backend, and I python-pipenv-activate t set as well. I have a .venv file in the directory of my python project, and when I open a file it correctly start the language server (which is only in the virtual environment) and activates the venv. However, I still get Importmagic and/or epc not found. importmagic.el will not be working. whenever the LSP activates, even though I've confirmed that I can import importmagic and import epc successfully.

I'm running the develop branch (cloned yesterday).

@yssource
Copy link
Contributor

yssource commented Jun 1, 2019

The problem is not really activate your virtual environment, which has importmagic or epc installed.

  • activate your virtual environment in shell and
    pip install -U importmagic epc
  • open python file in emacs, , v a pyven-activate invokes your real virtual environment.

Or doing this in org-mode.

  • pyvenv-activate your real virtual environment.

For my personal example.

#+BEGIN_SRC elisp :results silent
  (pyvenv-activate "/home/jimmy/.venvs/quant-6R1YVBAt-/home/jimmy/.pyenv/shims/python")
#+END_SRC
  • now virtual environment is ready for you.

#+begin_src python :results output
  import sys
  print(sys.executable)
#+end_src

#+RESULTS:
: /home/jimmy/.venvs/quant-6R1YVBAt-/home/jimmy/.pyenv/shims/python/bin/python

#+begin_src bash :results output
  ls -al /home/jimmy/.venvs/quant-6R1YVBAt-/home/jimmy/.pyenv/shims/python/
#+end_src

#+RESULTS:
: total 28
: drwxr-xr-x 6 jimmy jimmy 4096 May 29 15:10 .
: drwxr-xr-x 3 jimmy jimmy 4096 May 29 15:00 ..
: drwxr-xr-x 3 jimmy jimmy 4096 May 31 14:52 bin
: drwxr-xr-x 2 jimmy jimmy 4096 May 29 15:00 include
: drwxr-xr-x 3 jimmy jimmy 4096 May 29 15:00 lib
: lrwxrwxrwx 1 jimmy jimmy    3 May 29 15:00 lib64 -> lib
: -rw-r--r-- 1 jimmy jimmy   24 May 29 15:00 .project
: drwxr-xr-x 2 jimmy jimmy 4096 May 29 15:10 src

In summary,

  • importmagic or epc should be installed in one of your site-packages
    You can check it by python -m site
    For me it is:
    /home/jimmy/.venvs/quant-6R1YVBAt-/home/jimmy/.pyenv/shims/python/lib/python3.7/site-packages/importmagic
    /home/jimmy/.venvs/quant-6R1YVBAt-/home/jimmy/.pyenv/shims/python/lib/python3.7/site-packages/epc
  • correctly pyvenv activate your real virtual environment.

@docpuneet
Copy link

After doing pip install importmagic epc
I have a strange pop up window opening and distorting my KDE desktop whenever i open a python file in spacemacs????

@github-actions
Copy link

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Please let us know if this issue is still valid!

@github-actions github-actions bot added the stale marked as a stale issue/pr (usually by a bot) label Mar 16, 2021
@tokuchan
Copy link

I too face this problem. I'm running the anaconda backend, and I've installed importmagic and epc to my system python, on OSX yet I still have this problem.

@github-actions github-actions bot removed the stale marked as a stale issue/pr (usually by a bot) label Oct 17, 2021
@prehensilecode
Copy link

I have Python 3.9 installed via Homebrew (on macOS 10.15.7). Also kept having the same error message even after installing epc and importmagic. The message went away when I did pip3 install ipython.

Might also have a look at the customize variable exec-path and make sure the directory containing the Python you want is early in the list.

@fgiasson
Copy link
Contributor

For people that may be redirected to this issue, I have some more to contribute to it. I was facing the same issue, but everything was looking right regarding the environments, etc.

My setup is:

  • lsp
  • pyright
  • pyenv

However, what I noticed after trying to run multiple Python code blocks and closed Emacs that several epc servers where still running and hanging:

image

When clicking on one of them I was seeing another error:

image

Indeed, iPython was not installed in the virtual environment. A simple:

pip install ipython

reloading Emacs, and the error was gone. The problem was not that importmagic was not installed, but that it was missing another piece to be installed.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

10 participants