jorgenschaefer / elpy

Emacs Python Development Environment
GNU General Public License v3.0
1.9k stars 261 forks source link

Error in OS X When run python code with Special Characters #1060

Open jameswq opened 7 years ago

jameswq commented 7 years ago

hi, when I c-c c-c to run xxx.py with special characters as below: 1 the left was my python code ,the right was the result including the special characters so I don't know the reason why. thanks advanced. ` my init.el config as below: ;;;;;;;;;;;;apperance;;;;;;;;;;;;;;;;;; (add-to-list 'custom-theme-load-path "~/.emacs.d/themes") (load-theme 'spolsky t)

(tool-bar-mode 0) (scroll-bar-mode 0) (set-cursor-color "white") (set-mouse-color "white")

(setq frame-title-format "turtle's@%b") (setq inhibit-startup-message t) (setq gnus-inhibit-startup-message t)

;;;;;;;;;;;;;;;;;;date;;;;;;;;;;;;;;;;;;;;;;;;;;;;; (display-time-mode 1) (setq display-time-24hr-format t) (setq display-time-day-and-date nil) (setq display-time-interval 60)

;;;;;;;;;;;;;;;;;;;;; begin ecb ;;;;;;;;;;;;;;;;;;;;;;; (add-to-list 'load-path "~/.emacs.d/plugins/ecb") (require 'ecb) (setq ecb-auto-activate t ecb-tip-of-the-day nil)

;;;;;;;;;;;;;;;;;;;;; end ecb ;;;;;;;;;;;;;;;;;;;;;;;

(require 'package) (add-to-list 'package-archives '( "elpy" . "http://jorgenschaefer.github.io/packages/" ))

(package-initialize) (when (memq window-system '(mac ns)) (exec-path-from-shell-initialize))

(require 'elpy nil t) (exec-path-from-shell-copy-env "PATH") (elpy-enable) (elpy-use-ipython)

(custom-set-variables ;; custom-set-variables 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. '(package-selected-packages (quote (elpy)))) (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. )

jorgenschaefer commented 7 years ago

Yes, IPython does not adhere to common best practices when writing terminal programs and breaks Emacs.

Does adding (setenv "IPY_TEST_SIMPLE_PROMPT" "1") to your init file help?

jameswq commented 7 years ago

Dear Jorgen, after adding (setenv "IPY_TEST_SIMPLE_PROMPT" "1") to my init.el ,when I first run c-c c-c the message as below: 22 and when I second run c-c c-c the message as below: 33 my init.el as below:

(require 'python)
;;(setq python-command "ipython")
(setenv "IPY_TEST_SIMPLE_PROMPT" "1")
(setq python-shell-interpreter "ipython"
          python-shell-interpreter-args ""
          python-shell-prompt-regexp "In \\[[0-9]+\\]: "
          python-shell-prompt-output-regexp "Out\\[[0-9]+\\]: "
          python-shell-completion-setup-code
          "from IPython.core.completerlib import module_completion"
          python-shell-completion-module-string-code
          "';'.join(module_completion('''%s'''))\n"
          python-shell-completion-string-code
          "';'.join(get_ipython().Completer.all_completions('''%s'''))\n")

I don't know the reason why? thanks advanced!

jorgenschaefer commented 7 years ago

There seems to be a bug in Emacs about readline support (see #887).

Really, I'd recommend not using IPython within Emacs. Either use standard CPython in Emacs or IPython in a real terminal.

jameswq commented 7 years ago

Dear Jorgen, I really appreciate your geneous help.

jameswq commented 7 years ago

Dear Jorgen, i installed anaconda , then run c-c c-c,then following message without any special Characters 22 55

jorgenschaefer commented 7 years ago

Anaconda is a mode unrelated to and incompatible with Elpy. It won't fix this bug in emacs core.