I have a Windows 10 machine, with the official GNU emacs Windows build, and Anaconda Python 3.7.3. I can't get Python to properly run within emacs. Whenever I start Python, I get the message:

Python 3.7.3 (default, Mar 27 2019, 17:13:21) [MSC v.1915 64 bit (AMD64)] :: Anaconda, Inc. on win32

This Python interpreter is in a conda environment, but the environment has not been activated.  Libraries may fail to load.  To activate this environment please see https://conda.io/activation

Type "help", "copyright", "credits" or "license" for more information.

And numpy, scipy, etc won't load. I have tried several things with the pyvenv and elpy packages, all to no avail. From a DOS prompt, I type 'activate' to activate the conda env. I haven't setup any venv's of my own.


Provided that you added the folders paths of your conda install in Windows' %PATH% variable[*], the following should work :

  1. M-x shell

  2. In the shell, run conda activate base. This will load the environment and allow you to use the libraries (like numpy).

  3. In the same shell, run python -i (or ipython -i). The -i forces a prompt. Without it, the shell hangs in Emacs, I don't know why (it doesn't in cmd).

I personally automated this process by creating a batch file called my-python.bat. I placed it in a folder named my-batch-files which I have referenced in %PATH% [*]. Here's the bat file :

@echo off
conda activate base && python -i

That way you can call directly my-python from the shell — whether it be on Emacs or on cmd — and have a working ipython shell, with all DLLs loaded.

Plus, if you change python-shell-interpreter to my-python, you get the default functions from python-mode run-python (C-c C-p) and python-shell-send-buffer (C-c C-c) working.

Caveat : At this time, images' display (with matplotlib.pyplot) still does not work properly. I'm working on it. If someone has ideas...

[*] Windows -> Environment variables -> System Variables -> Path -> Edit. The paths should look like this (check them beforehand !) : C:\Users\YOUR_USER_NAME\AppData\Local\Continuum\anaconda3\Scripts and C:\Users\YOUR_USER_NAME\AppData\Local\Continuum\anaconda3.

You'll have to relaunch the shell (and Emacs !) for the environment variables to be taken into account. You can check the variable value by typing echo %PATH% in your shell.

  • Note: this worked for my replacing conda activate base with just activate base. – pglpm Apr 4 '20 at 15:22

This solved my issue of numpy failing to load on import when using Anaconda3/python on Windows 10 from my Emacs session:


  • 1
    Welcome to emacs.SE! Please avoid providing link-only answers. Try to summarize how the issue is solved, this is will make it potentially much more usefull in the future. – JeanPierre Oct 7 '19 at 13:34

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.