0

I am a new emacs user and was following the guide here:

https://realpython.com/emacs-the-best-python-editor/

In order to set up emacs as my default IDE. I have anaconda installed and updated.

I ran into a couple of problems with my init.el file but I think I have it in a place where emacs is happy to start without an error now:

;; init.el --- Emacs configuration

;; INSTALL PACKAGES
;; --------------------------------------

(require 'package)

(add-to-list 'package-archives
       '("melpa" . "http://melpa.org/packages/") t)

(package-initialize)
(when (not package-archive-contents)
  (package-refresh-contents))

(defvar myPackages
  '(better-defaults
    ein
    elpy
    flycheck
    material-theme
    py-autopep8))

(mapc #'(lambda (package)
    (unless (package-installed-p package)
      (package-install package)))
      myPackages)


;; BASIC CUSTOMIZATION
;; --------------------------------------

(setq inhibit-startup-message t) ;; hide the startup message
(load-theme 'material t) ;; load material theme

;; PYTHON CONFIGURATION
;; --------------------------------------

(setq python-shell-interpreter "ipython"
      python-shell-interpreter-args "-i --simple-prompt")

;; use flycheck not flymake with elpy
(require 'elpy)
(when (require 'flycheck nil t)
  (setq elpy-modules (delq 'elpy-module-flymake elpy-modules))
  (add-hook 'elpy-mode-hook 'flycheck-mode))

;; enable autopep8 formatting on save
(require 'py-autopep8)
(add-hook 'elpy-mode-hook 'py-autopep8-enable-on-save)



;; init.el ends here

But when I try to run some simple python code:

x = "There are %d types of people." % 10
binary = "binary"
do_not = "don't"
y = "Those who know %s and those who %s" % (binary, do_not)

print x
print y

print "I said: %r" % x
print "I also said: '%s'." % y

hilarious = false
joke_valuation = "Isn't that joke so funny?! %r"

print joke_evaluation % hilarious

w = "This is the left side of..."
e = "a string with a right side."

print w + e

with C-c C-c it asks me to start a python process first, but when I try C-c C-p it returns "Searching for program: no such file or directory, ipython."

But if I try 'conda install ipython' in anaconda it tells me it is already installed, as it comes with the base version of conda.

I'm sure I'm misunderstanding something simple but I can't seem to work out what I'm doing wrong.

  • What does which ipython in the terminal give you? – Mic May 13 '18 at 12:55
  • (base) C:\Users\Chris>which ipython 'which' is not recognized as an internal or exte operable program or batch file. (base) C:\Users\Chris>where ipython C:\Users\Chris\Anaconda2\Scripts\ipython.exe – Violatic May 13 '18 at 13:06
  • Please tell more about your system. What does ipython gives in a terminal? It looks like ipython is not in your path, so the command that the emacs package issues fails. I might be wrong. – Mic May 13 '18 at 13:07
  • (base) C:\Users\Chris>ipython Python 2.7.14 |Anaconda, Inc.| (default, Nov 8 2017, 13:40:45) [MSC v.1500 64 b it (AMD64)] Type "copyright", "credits" or "license" for more information. IPython 5.6.0 -- An enhanced Interactive Python. ? -> Introduction and overview of IPython's features. %quickref -> Quick reference. help -> Python's own help system. object? -> Details about 'object', use 'object??' for extra details. In [1]: You could be right about it not being in the path, how do I check / add it if it's not? – Violatic May 13 '18 at 13:08
  • 1
    MS Windows equivalent of which ipython is where ipython. ipython needs to be on OS path (to check what Emacs sees as your path try evaluating in shell / term buffer echo %path%). Alternatively, you can M-x getenv path. Emacs will typically use the system path to populate its exec-path too, but if you made changes after starting Emacs, or Emacs is started by a different user, your path may, of course be different. You may then need to modify its configuration (eg. by calling M-x setenv path newpath) to make it see the executable you are trying to run. – wvxvw May 13 '18 at 14:01

Your Answer

By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.

Browse other questions tagged or ask your own question.