Hot answers tagged

23

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, ...


8

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


8

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.pycqa.org/en/latest/user/configuration.html#user-configuration


8

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


8

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


6

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 :...


5

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


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

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

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, ...


4

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.


4

(setq elpy-rpc-virtualenv-path 'current) works for me.


4

There's a workaround suggested in https://github.com/jorgenschaefer/elpy/issues/1381#issuecomment-434313600 Adding (setq elpy-eldoc-show-current-function nil) to my emacs init file makes it stop happening for me. Good enough!


3

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


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

Have you tried to delete elpy package from M-x list-packages? You can do it by pressing d on the elpy package, and then pressing yes to confirm the action. If you already did that, you can go to ~/.emacs.d and delete the elpy folder created when you installed it. Hope this help you.


3

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 ((...


3

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.


3

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


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

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


3

You should create in your home folder a .flake8rc file, and add some content to ignore that error - documented here and below is a small template: [flake8] # it's not a bug that we aren't using all of hacking ignore = # F812: list comprehension redefines ... F812, # H101: Use TODO(NAME) H101, # H202: assertRaises Exception too broad ...


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

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

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

Set the interpreter variable in your .emacs file: (setq python-shell-interpreter "python3" python-shell-interpreter-args "-i") Taken from elpy manual


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

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


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