spacemacs icon indicating copy to clipboard operation
spacemacs copied to clipboard

importmagic freezing Emacs startup

Open lukeorland opened this issue 6 years ago • 14 comments

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 :beetle:

  • Start Emacs

Observed behaviour: :eyes: :broken_heart:

Frozen on startup.

Expected behaviour: :heart: :smile:

Not frozen on startup.

System Info :computer:

  • OS: gnu/linux
  • Emacs: 25.3.1
  • Spacemacs: 0.300.0
  • Spacemacs branch: develop (rev. 86ff0eb8)
  • 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 avatar Jan 12 '18 19:01 lukeorland

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 avatar Jan 12 '18 19:01 lukeorland

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 avatar Jan 12 '18 19:01 lukeorland

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

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

lukeorland avatar Jan 12 '18 19:01 lukeorland

Can you try to call:

(require 'pyvenv)
(pyvenv-activate DIRECTORY)

In your dotspacemacs/user-config directory.

syl20bnr avatar Jan 13 '18 03:01 syl20bnr

@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.

anachronic avatar Nov 07 '18 22:11 anachronic

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 https://github.com/proofit404/anaconda-mode/issues/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.

mgorfer avatar Nov 13 '18 20:11 mgorfer

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.

yssource avatar May 24 '19 13:05 yssource

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).

albertmichaelj avatar May 28 '19 19:05 albertmichaelj

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.

yssource avatar Jun 01 '19 05:06 yssource

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????

docpuneet avatar Mar 16 '20 17:03 docpuneet

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[bot] avatar Mar 16 '21 17:03 github-actions[bot]

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.

tokuchan avatar Aug 10 '21 15:08 tokuchan

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.

prehensilecode avatar May 04 '22 23:05 prehensilecode

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.

fgiasson avatar Oct 18 '23 17:10 fgiasson