Hot answers tagged

16

You can conffigure elpy-rpc-python-command. If you want Python3 you can set it like this. (setq elpy-rpc-python-command "python3") Update Create python3 virtualenv using virtualenvwrapper from terminal $ mkvirtualenv test -p /usr/bin/python3 and then install required packages $ pip install rope jedi importmagic autopep8 flake8 Now go to emacs, ...


7

flymake uses flake8 to check the errors, so you have to tell flake8 which errors you don't want to see. You can do that globally by creating the file ~/.config/flake8, with the following content: [flake8] ignore = E303 You can also create a setup.cfg at the root of your project, with the same syntax, to have different settings per project. Make sure to ...


6

I don’t know Elpy, so I’m not sure whether I understand your problem correctly. I do know use-package, though, and recently suffered from the very same issue, namely the removal of :idle. Basically, there are two ways out, depending on how you need to use Elpy. You can either use a poor man’s :idle, with run-with-idle-timer, e.g. :init (run-with-idle-...


5

I don't use eply, I use emacs 25.1.1 with company-jedi with the following: (setq python-shell-interpreter "ipython3" python-shell-interpreter-args "--simple-prompt --pprint") Inside emacs *Python* Python 3.6.0, Anaconda 4.3.0, Ipython 5.1.0 In[1]: x = 10 In[2]: x = 125 In[3]: x = # type M-p I get history items 1 and 2 and Input restored. That ...


4

rgrep takes as its second argument file description in a format similar to shell globbing, which also exists in other languages, for example, in Python. There's also a useful variable in Emacs related to rgrep: grep-files-aliases, which can be customized to alias various file groups, for instance (push (cons "pyml" "*.py *.htm *.html") grep-files-aliases) ...


4

You can solve this by modifying the python shell configuration from python to python3 in elpy-config M-x elpy-config to enter the configuration page of elpy if you scroll down you will see groups with [+] signs, toggle the Python one and find the shell interpreter option: Option Python Shell Interpreter is the one you are looking for. If you click (or Enter ...


4

Well I figured it out: kill-process kills the process as a side effect, so it returns before that is really killed. So a function like this works: (defun my-restart-python-console () "Restart python console before evaluate buffer or region to avoid various uncanny conflicts, like not reloding modules even when they are changed" (interactive) (kill-...


4

If you want to customize per project basis, you can create a setup.cfg with custom config like this [flake8] max-line-length = 160 If you want to change this globally, you can change flake8 config as mentioned here https://flake8.readthedocs.io/en/latest/config.html#global


4

When you spot a problem in the way how emacs behaves and if that happens only when you load your emacs config (init.el or .emacs) and not when you run emacs -Q, you need to bisect your init to find the culprit as @Drew mentioned in the comments. Fortunately, you don't have to bisect your init in this case as you have a tangible visual clue of the problem. ...


4

Reading the docstring for the deprecated elpy-use-ipython, it points to https://elpy.readthedocs.io/en/latest/ide.html#interpreter-setup that recommends the following setup for ipython: (setq python-shell-interpreter "ipython" python-shell-interpreter-args "-i --simple-prompt") If it still fails, you could try using full path to your ipython ...


3

This should be fixed as of the docs By default, Elpy tries to find the root directory of the current project (git, svn or hg repository, python package or projectile project) and starts the python interpreter here. This behaviour can be suppressed with the option elpy-shell-use-project-root. The order seems to be projectile root, then python project, ...


3

elpy has a function elpy-open-and-indent-line-below which is binded to <S-return>. After """, you can hit <S-return> to open new line and indent automatically. You can use this at the end of line. Alternatively, you can bind return to this function. (define-key elpy-mode-map (kbd "<return>") 'elpy-open-and-indent-line-below)


3

You can install jedi/yapf packages in a separate virtualenv and just add $VIRTUAL_ENV/lib/python*/site-packages/ to your PYTHONPATH or to your virtualenv using add2virtualenv. Make sure you are using the same Python version for both virtualenvs. Alternatively, you can install Elpy and the other packages globally (or user-local) and use the --system-site-...


3

To work on a virtual environment, you need to call M-x pyvenv-workon and then select the preferred working environment. There is no need to install other packages as elpy comes with pyvenv package.


3

This is an old bug. It has been resolved with this patch: https://github.com/jorgenschaefer/elpy/pull/1279


2

You should be able to just enable company-mode globally without any problems with Elpy (if there are any, please do file a bug report!). You can also use auto-complete in buffers other than Python mode buffers (auto-complete supports different backends from company-mode, so might be preferable for some), by removing python-mode from ac-modes. This will then ...


2

The author of elpy suggests doing this via an advice, because elpy-enable modifies the python-mode-hook variable, so calling it inside the mode-hook is too late: https://github.com/jorgenschaefer/elpy/wiki/Configuration simple approach: (package-initialize) (advice-add 'python-mode :before 'elpy-enable) using use-package: (use-package elpy :ensure t :...


2

I think it is possible with :after (use-package python :ensure t :defer t :mode ("\\.py\\'" . python-mode)) (use-package elpy :ensure t :after python :config (elpy-enable))


2

The problem is ultimately the result of misunderstanding how completion works with company mode. I temporarily solved it by adding an import statement to the top of the org-babel block. That is, typing, say sys. and awaiting the completion candidates that come with the sys module proved fruitless. However, beginning that same org-babel block with import ...


2

Elpy knows of two "roots" for your directory, the "project root" and the "library root". The project root is used for file searches and similar, while the library root is the directory added to sys.path. In your example, my_project/ should be the project root, while my_project/src/ should be the library root. You can verify this using M-: (elpy-project-root)...


2

If you're using ipython, why not just use the baked-in %reset magic command? You can also use: %load_ext autoreload %autoreload To automatically reload imported modules on change.


2

ipython 5.0.0 by defautl uses prompt_toolkit which is really nice in a terminal but uses special characters for colors and completion that screws emacs display. Eventually it should be fixed but for now I have this in my .emacs: (setq python-shell-interpreter "ipython3" python-shell-interpreter-args "--simple-prompt --pprint") and run M-x run-...


2

Elpy doesn't require emacs jedi package. Also they won't work well when both are configured. I guess there is some conflict between them. Use only elpy and you should be able to get completion in rpc buffer. I created an empty file with class Foo: this = 2 After sending this to python buffer with C-C C-c, if i switch to python buffer and type Foo. ...


2

A solution that I found over on Stackoverflow was the following proposed here for a UnicodeDecodingError, which did work for me: (setenv "LANG" "en_US.UTF-8") (setenv "LC_ALL" "en_US.UTF-8") (setenv "LC_CTYPE" "en_US.UTF-8") I only actually required the first of the three lines in my case. Further suggestions specific to Python are in this post, namely to ...


2

This seems to be bug in emacs and its fixed in this commit. As npostavs mentioned, you can use (with-eval-after-load 'python (defun python-shell-completion-native-try () "Return non-nil if can trigger native completion." (let ((python-shell-completion-native-enable t) (python-shell-completion-native-output-timeout python-...


2

I haven't tried this thoroughly, but should work: 1. if region is active, evaluate it (this currently works), goto 3. 2. if region not active, evaluate current statement, goto 3. 3. Jump to the beginning of next paragraph (defun python-shell-send-region-or-line nil "Sends from python-mode buffer to a python shell, intelligently." (interactive) (cond ((...


2

You can use local-set-key in the major mode's hook. If you do that you don't even need to know the specific keymap for that mode. You can paste the following lisp code into your init file to have the binding Ctrl-RET for elpy-shell-send-statement-and-step. Disclaimer: I didn't try it. Please test it. (defun my-elpy-mode-hook-fun () "Function to be ...


2

Answered at github: You can set elpy-shell-use-project-root to nil to start the shell in the directory of the Python file as before. Alternatively, modify your MyProject/Python directory so that it is detected as a project root; see elpy-project-root-finder-functions. The elpy-project-root-finder-functions have the options: Projectile project ...


1

You can temporarily change the default root before switching to the elpy shell: (defun elpy-shell-switch-to-shell-in-root () "Switch to python shell starting in project root" (interactive) (let ((default-directory (elpy-project-root))) (elpy-shell-switch-to-shell)) )


1

I use the following: (setq python-shell-interpreter "ipython3" python-shell-interpreter-args "--simple-prompt --pprint") For python 3.6 I found jedi with company to be the most reliable but others may have different experiences. "mypath" below are the paths to packages I've created that I want autocomplete. (use-package company-jedi :config (...


Only top voted, non community-wiki answers of a minimum length are eligible