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

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

Open
joostkremers opened this issue Dec 9, 2021 · 5 comments
Open

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

joostkremers opened this issue Dec 9, 2021 · 5 comments

Comments

@joostkremers
Copy link

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
Copy link
Author

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
Copy link
Owner

necaris commented Mar 13, 2022

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

@necaris
Copy link
Owner

necaris commented Jun 28, 2022

@joostkremers any more details here?

@joostkremers
Copy link
Author

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

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

@snunez1
Copy link

snunez1 commented Feb 6, 2024

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.

@necaris necaris added the windows label Oct 5, 2024
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

3 participants