Oct. 2021 update: I am at my wit's end over this. Still Windows 10, official GNU emacs 27.2. Anaconda installed in c:\users\[username]\Anaconda3. No venv's, I just use the base conda environment. Please please tell me what exactly to type in my .emacs file, so that "M-x run-python" starts the anaconda python, properly activates so "import numpy" works. Please! I've flailed around w/ pyvenv.el, conda.el, I give up.

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.

  • From the warning message in your posting - see this page: docs.conda.io/projects/conda/en/latest/user-guide/tasks/… for detailed windows configuration.
    – Ian
    Commented Jul 13, 2019 at 15:25
  • Try conda.el package github.com/necaris/conda.el/blob/master/conda.el It switches between conda environments
    – mmmmmm
    Commented Oct 7, 2021 at 8:31
  • Thanks, but I can't figure out how to get this to work. By "work", I mean "M-x run-python" starts Anaconda python, with the env activated so numpy works. I have "(require 'conda)" in my init.el, and with or without "'(conda-anaconda-home "c:/Users/strozzi2/Anaconda3")" it doesn't work. "M-x conda-env-list" works (so the package is loaded) but lists nothing. "M-x conda-env-activate" asks what env to activate. <blank> and "base" both give "No such conda environment." I am stumped.
    – D Strozzi
    Commented Oct 8, 2021 at 16:37

2 Answers 2


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
    Commented Apr 4, 2020 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
    Commented Oct 7, 2019 at 13:34

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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