necaris / conda.el

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

Trouble getting started on Windows #94

Open dstrozzi opened 3 years ago

dstrozzi commented 3 years ago

OK I am pretty confused! I am trying to use Python inside emacs 27.2 (the plain version straight from GNU) on Windows 10. I use Anaconda Python, 3.8.8, just the plain base env, I haven't setup my own venv's. By "use Python inside emacs", I do not mean from a shell run within emacs. But, what "M-x run-python" does. I.e., emacs directly runs Python, you don't start a shell and then run Python. Then emacs becomes a nice IDE. I do this all the time on Linux.

To be explicit, my init.el is below, the whole thing. The only relevant lines, I think, are (require 'conda) '(conda-anaconda-home "c:/Users/strozzi2/Anaconda3") ;; my base Anaconda dir; has python.exe and everything else

Whether the 2nd line is included or not, "M-x run-python" gives "Python was not found; run without ...". In the past, I was able to get emacs to at least find and start Python, though without conda env activated (so numpy and everything else didn't work). But, my init.el got very confusing, and I want to start over and do it right.

So, question 1: how do I setup emacs so it can find and start python?

Thank you, Dave

;; 8oct21: new beginning
;; Notes on emacs commands:
;; require: load file once;  load: load file, even if already has been.

;;emacs activates any optional installed packages, unless you set this.
(setq package-enable-at-startup nil)

;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; emacs general ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
(setq inhibit-splash-screen t)         ;; t: no splash screen
(setq initial-scratch-message "")      ;; "": start without standard scratch comment
(global-linum-mode 1)                  ;; 1: linum mode by default, can be slow on big files
(setq linum-format "%4d ")             ;; 4 chars (space plus num), and one space b/t
;;                                     ;; linum numbers on left and text
(set-face-background 'linum "lightgray")
;(set-face-foreground 'linum "gray")
(setq column-number-mode t)            ;; column number mode on by default
(setq use-file-dialog nil)             ;; no file dialog boxes
(setq-default indent-tabs-mode nil)    ;; Prevent Extraneous Tabs
(set-language-environment "UTF-8")     ;; 17aug18: for UTF-8; UFT-8-{dos, unix} NOT valid!
(prefer-coding-system 'utf-8-unix)     ;; 17aug18 should give unix newlines by default for new files
;;                                     ;; Create new text file, mode line has U(Unix) on Windows.
;;                                     ;; Type in pure ascii, save, re-open, mode-line -(Unix)
;;                                     ;; i.e. no special encoding detected
(tool-bar-mode nil)
(savehist-mode 1)                      ;; save history like commands across sessions

(server-start)                         ;; so clients can connect: e.g. SumatraPDF tex inverse search

(custom-set-faces
 ;; custom-set-faces was added by Custom.
 ;; If you edit it by hand, you could mess it up, so be careful.
 ;; Your init file should contain only one such instance.
 ;; If there is more than one, they won't work right.
 '(default ((t (:family "Consolas" :foundry "outline" :slant normal :weight normal :height 113 :width normal)))))
(put 'downcase-region 'disabled nil)

(require 'recentf)  (recentf-mode 1)   ;; recent files menu
(load "auctex.el" nil t t)
(require 'w32-browser)

;; Use anaconda env in emacs
(require 'conda)
'(conda-anaconda-home "c:/Users/strozzi2/Anaconda3")

;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; FUNCTION KEYS ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;(global-set-key [f1] 'linum-mode)  prolly no need to turn off on laptop routinely
(global-set-key [f2] 'shell)
;; f3 f4 yorick on LC
;;(global-set-key [f5] 'python-shell-switch-to-shell)
;;(global-set-key [f6] 'python-shell-send-region)
(global-set-key [f7] 'buffer-menu)
(global-set-key [f8] 'goto-line)     ; emacs default meta-g g
(global-set-key [f9] 'undo)
joostkremers commented 2 years ago

To be explicit, my init.el is below, the whole thing. The only relevant lines, I think, are

'(conda-anaconda-home "c:/Users/strozzi2/Anaconda3")

That line is most definitely incorrect. It won't raise an error, but it does not do anything, either. (You probably copied it from a custom-set-variables, right?) Try the following instead:

(setq conda-anaconda-home "c:/Users/strozzi2/Anaconda3")

That should work. (Note, though, that I just stumbled upon this while looking to see if I can use Emacs for Python development on Windows. I'm not actually using conda.el myself yet.)

dstrozzi commented 2 years ago

Thanks very much for the reply! Yes, that was a dumb error on my part. But I must admit I still can't get things to "work". Meaning: M-x run-python starts Python in emacs, with the Anaconda env. Relevant init.el lines:

<stuff to activate packages>
(custom-set-variables
'(package-selected-packages '(conda)))
(require 'conda)
(setq conda-anaconda-home "c:/Users/strozzi2/Anaconda3")
(conda-env-autoactivate-mode t)

Now, M-x conda-env-list returns base. I can do M-x conda-env-activate base, I get some msg about 1 arg given 2 expected. But if I do it again, it says base is active. Either way, whether I activate base or not, M-x run-python gives the standard Microsoft msg about no python installed, you can download from Msft store.

Any thoughts?

necaris commented 2 years ago

Have you had any luck getting started with Python, @dstrozzi?

dstrozzi commented 2 years ago

No news. I've given up on this for now. I think the Venn diagram of Python + Anaconda + windows + emacs users is just too small. I am out on an island.