Open fjs2097 opened 8 years ago
Hello, and thanks for the question! There are multiple ones, so let's address each in turn :-)
it does not seem to work (no auto-fill, or syntax error checking etc...).
Can you confirm Elpy mode is active at all? E.g. is there an Elpy
string in the mode line? Does C-c C-o
work?
If so, what does M-TAB
and C-c C-d
do?
I also made sure to add the ~/.local/bin/ folder to my Path by writing (add-to-list 'load-path "~/.local/bin/")
All the syntax check problems are because of a misunderstanding here. load-path
is where Emacs tries to find Emacs Lisp files. Elpy needs the flake8
program in the system PATH
. You probably want to add ~/.local/bin
to PATH
in your shell, or, depending on what environment (OS, desktop, etc.) you run Emacs in, you can try and add it to exec-path
instead of load-path
. Verify it works by using C-c C-v
.
Does this help?
Thank you for your quick answer! The 'exec-path' solved the syntax error checking issue. I tried a bunch of things after sending my questions yesterday, hence there had been some improvement ( Python||elpy was showing in the mode line and the autofill seemed to be working fine, M-Tab included) but the error checking was still not working, as highlighted byt the following error occuring when I pressed C-C C-v :
-- mode: compilation; default-directory: "~/Documents/" -- Compilation started at Wed May 11 10:22:57
flake8 /home/fj/Documents/firstproject.py /bin/bash: flake8: command not found
Compilation exited abnormally with code 127 at Wed May 11 10:22:57
The interesting thing though is that even before I fixed the exec-path thing, flake8 was functional after activating a virtual environment, not sure why. As a follow up question, if ok, would you mind telling me the advantages of working in a virtual environment vs not?
Thanks you so much for all your answers and quick turnaround.
The interesting thing though is that even before I fixed the exec-path thing, flake8 was functional after activating a virtual environment, not sure why.
That would indicate that flake8 was installed in that virtualenv :-)
would you mind telling me the advantages of working in a virtual environment vs not?
A virtualenv means you can install dependencies of your project in one spot, and have an isolated environment with exactly the dependencies of your project in the versions required by your project. If you work on another project, you can use a different virtualenv for that.
http://docs.python-guide.org/en/latest/dev/virtualenvs/ has some basic info on that.
actually, it was working earlier, but after doing a package-refresh-contents and installing flycheck and autopep8, I now get the following error when doing C-c C-v :
/bin/bash: flake8: command not found
Compilation exited abnormally with code 127 at Wed May 11 13:07:33
not sure what happened in between...
You have to make sure that flake8
is in your PATH
– it's a bit tricky to figure out why it isn't remotely.
Yes, flake8 is in .local/bin, which I added to the path earlier using the 'exec-path' as you suggested. C-c C-v was working fine until I installed flycheck and autopep and now it is giving me this error again, as if it was looking for in /bin/bash folder (which does not exist)? M-x elpy config now say that flake8 is installed and gives me no error message on the .local/bin folder (see below)
/bin/bash: flake8: command not found
Compilation exited abnormally with code 127 at Wed May 11 13:07:33
Elpy Configuration
Virtualenv........: None
RPC Python........: 2.7.10 (/usr/bin/python)
Interactive Python: python (/usr/bin/python)
Emacs.............: 24.5.1
Elpy..............: 1.12.0
Jedi..............: 0.9.0
Rope..............: 0.10.3
Importmagic.......: 0.1.7
Autopep8..........: 1.2.2
Yapf..............: 0.8.0
Syntax checker....: flake8 (/home/fj/.local/bin/flake8)
You have not activated a virtual env. While Elpy supports this, it is
often a good idea to work inside a virtual env. You can use M-x
pyvenv-activate or M-x pyvenv-workon to activate a virtual env.
Options
`Raised' text indicates buttons; type RET or click mouse-1 on a button
to invoke its action. Invoke [+] to expand a group, and [-] to
collapse an expanded group. Invoke the [Group], [Face], and [Option]
buttons below to edit that item in another window.
Elpy uses /bin/bash
to run the command you specify for syntax checks. /bin/bash
can not find flake8
. You will have to make sure that /bin/bash
can find flake8
. As I said, exec-path
will be a bit limited (it only affects Emacs), you really want to add $HOME/.local/bin
to PATH
.
I got the same problem because i use zsh....
I find a work around in adding that in my .emacs
(setenv "PATH" (concat (getenv "PATH") ":/home/tlu/.local/bin"))
(setq exec-path (append exec-path '("/home/tlu/.local/bin")))
I still have the problem for virtualenv. If you have idea...
I do not use zsh so can not help you with that tool.
You can set the flake8 executable in the elpy configuration group Like this [-]-\ Group Elpy . . . `--- # Option Elpy Syntax Check Command Select option and put the path to flake8 executable.
Hide Elpy Syntax Check
Command: /home/{user}/.local/bin/flake8 [Or other Path]
I think this can solve your issue.
To add why the solution works:
In my case, the flake8 string (path) was simply flake8
which works in a default (global) non-virtual environment
But that command fails when you do not have flake8 in the activated virtual environment
Changing the string (path) to an explicit location like /my/bin/directory/flake8
fixes this issue.
Good reference from doc: https://elpy.readthedocs.io/en/latest/concepts.html
Hi there, I am a newbie to elpy and emacs. I am trying to install elpy so I can code some Python in Emacs and after going through the install guidelines defined by Elpy, it does not seem to work (no auto-fill, or syntax error checking etc...). I ran the elpy-config function and got the following
I made sure that flake8 was indeed installed (uninstalled and reinstalled it using pip and directly from the elpy-config window) but the message does not change. I also made sure to add the ~/.local/bin/ folder to my Path by writing (add-to-list 'load-path "~/.local/bin/") in my init file, but the " The directory ~/.local/bin/ is not in your PATH" error is still there.
Can you please help?
thanks so much