necaris / conda.el

Emacs helper library (and minor mode) to work with conda environments
MIT License
153 stars 51 forks source link

PATH doesn't seem set correctly on Windows 10 #100

Open joostkremers opened 2 years ago

joostkremers commented 2 years ago

I'm trying to set up conda.el on Windows, and I'm running into some problems. Initially, all I had in my init file was this:

(use-package conda
  :init
  (setq conda-anaconda-home "c:/Users/joost.kremers/Anaconda3"))

This seemed to leave my PATH unchanged when activating an environment: after M-x run-python, doing:

>>> import os
>>> print(os.environ.get("PATH"))

showed that the environment directories weren't added to PATH. (They were added to exec-path, though).

Once I changed the config to:

(use-package conda
  :init
  (setq conda-anaconda-home "c:/Users/joost.kremers/Anaconda3"))
  :config
  (conda-env-initialize-interactive-shells)
  (conda-env-initialize-eshell)

PATH looks correct, but there are still issues.

For one, I don't seem to be able to properly activate an environment with a Python version that does not correspond to the Python version in the base environment. base has Python 3.8.8, and if I activate an environment that has Python 3.7.12, I get the warning:

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

Then, if I exit the interpreter, deactivate the environment and try to activate one that has Python 3.8, M-x run-python still shows Python 3.7...

If an environment with Python 3.8 is the first environment I activate in an Emacs session, run-python doesn't give me this error.

Any idea what's going on here? Or tips where to start troubleshooting? I'm a bit at a loss, since I normally use Linux and I also haven't used conda before to handle my environments, so any help would be appreciated.

joostkremers commented 2 years ago

Perhaps related: If I run a shell after activating an environment (with M-x shell), the shell starts up but prints an error 'activate' is not recognized as an internal or external command, operable program or batch file. Typing conda activate <env_name> also doesn't work.

necaris commented 2 years ago

I haven't used Windows in a while, unfortunately; how do you activate an environment if you don't use conda activate?

necaris commented 2 years ago

@joostkremers any more details here?

joostkremers commented 2 years ago

Unfortunately, no. I've stopped using Windows, so I can't troubleshoot anymore. I did try removing Anaconda completely and using python-poetry instead to manage my environments, but never really got that working either. So I probably messed something up with my Python environment that also may have affected conda.el. (Either that or I'm just too stupid to use Windows. :smile: )

I'll leave it up to you whether to close this issue or not. As a bug report, it's probably not very useful... :disappointed:

snunez1 commented 8 months ago

In case someone finds this, I ran into similar problems. In this case, it was because python-shell-interpreter was set to python3.exe so, although conda.el did fix up the OS PATH and exec-path, emacs (run-python?) was falling through to the only python3.exe it could find, MSYS2's /usr/bin/python3.exe.

The fix is to set it as part of the conda.el init: (setq python-shell-interpreter "python"). It's still early in the python/emacs setup journey, but at least the environment is being activated.