Fresh install of Linux Mint 18.3 Cinnamon.
新安装的Linux Mint 18.3肉桂。
Also a fresh install of Gnu Emacs 24.5.1
还有一个全新的Gnu Emacs 24.5.1版本。
Also a fresh install of Anaconda3:
还有一种新安装的水蟒:
~ $ conda -version
usage: conda [-h] [-V] command ...
conda: error: the following arguments are required: command
~ $ conda -V
conda 4.4.10
~ $ python -V
Python 3.6.4 :: Anaconda, Inc.
~ $ anaconda -V
anaconda Command line client (version 1.6.9
Emacs has python-mode, python, and elpy installed, python code executed via ctrl+Enter
is run with the executable in /usr/bin/python
which is hopelessly out of date...2.7.2
Emacs已经安装了python模式、python和elpy,通过ctrl+Enter执行的python代码与/usr/bin/python中的可执行文件一起运行,这是无可救药的过时了……2.7.2
Executing python
on the command line
在命令行上执行python
~ $ which python
/home/user/anaconda3/bin/python
~ $ python
Python 3.6.4 |Anaconda, Inc.| (default, Jan 16 2018, 18:10:19)
Also, M-x elpy-config
yields an error: neither easy install nor pip can be found
very strange, given pip
was installed with anaconda3
另外,M-x elpy-config会产生一个错误:由于pip安装了anaconda3,因此既不容易安装也不容易发现pip非常奇怪
I don't know how to find what command elpy is using to run python or why elpy-config won't work, I assume that somewhere, it is hardcoded to the /usr/bin
directory to look for all of the above executables, but no place I look indicates this.
我不知道如何查找elpy用于运行python的命令,也不知道为什么elpy-config不能工作,我假设在某个地方,它被硬编码到/usr/bin目录,以查找上面所有的可执行文件,但是我找不到任何地方表明这一点。
2 个解决方案
#1
2
This is what I suspect happened.
这就是我猜想发生的事情。
When you configure $PATH
, there are a few different ways to do it. One of the most common ways to do it is by adding it to your .bashrc
(or .zshrc
, .profile
, whatever) file in your home directory. However, when you do this, this does not actually set $PATH
anywhere else... only for the shell itself, and for programs runn from the shell.
当您配置$PATH时,有几种不同的方法。最常见的一种方法是将它添加到主目录中的.bashrc(或.zshrc、.profile)文件中。但是,当您这样做的时候,它实际上并没有在其他地方设置$PATH…只适用于外壳本身,以及从外壳中运行的程序。
You can still launch programs from your window manager (e.g. Gnome, Cinnamon, KDE), and these programs will inherit $PATH
not from your shell, but from your X login session.
您仍然可以从窗口管理器(例如Gnome、肉桂、KDE)启动程序,这些程序将从您的shell继承$PATH,而不是从您的X登录会话继承。
So after updating $PATH
in .bashrc
, Emacs will not see that path because it's not being launched from Bash.
因此,在.bashrc中更新$PATH之后,Emacs将看不到该路径,因为它没有从Bash启动。
ASCII Art Time
X Session $PATH=<original $PATH> + + +---------+ +--------+ v v Terminal Emacs $PATH=<original $PATH> + | v bash $PATH=/home/user/anaconda3/bin:$PATH
Solution #1: Change $PATH in .emacs
This is pretty easy. Just add a line to your .emacs
near the top like this:
这是非常容易的。在顶部添加一行,像这样:
(setenv "PATH" "/home/user/anaconda3/bin:/home/user/bin:/home/user/.local/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/usr/local/game")
This has some drawbacks... because now you're setting $PATH
in two different places, and these two places can get out of sync with each other (you can forget to update one when the other changes).
这有一些缺陷…因为现在您正在两个不同的位置设置$PATH,这两个位置可能会相互不同步(当其他位置发生更改时,您可能会忘记更新一个位置)。
This is the solution I use.
这是我使用的解决方案。
Solution #2: Configure Elpy to use your Python
Elpy, like most Emacs packages, is configurable. See: https://emacs.stackexchange.com/questions/16637/how-to-set-up-elpy-to-use-python3
与大多数Emacs包一样,Elpy是可配置的。参见:https://emacs.stackexchange.com/questions/16637/how-to-set-up-elpy-to-use-python3
You might be able to use M-x customize-group "elpy" or something like that, which means you don't have to edit your .emacs
by hand.
您可能可以使用M-x定制组“elpy”或类似的东西,这意味着您不必手动编辑。emacs。
Solution #3: Change $PATH for your X session
Depending on the specifics of your setup there are different ways to do this. I believe moving the $PATH
definitions from .bashrc
to .profile
may work, but it's been a while since I've done this.
根据您的设置的具体情况,有不同的方法来实现这一点。我相信将$PATH定义从.bashrc移动到.profile可能是可行的,但是我已经有一段时间没有这么做了。
#2
0
The accepted answer has a nice explanation of what's going on.
公认的答案对正在发生的事情有一个很好的解释。
For a quick solution, Install this package: exec-path-from-shell
要获得快速解决方案,请安装这个包:exec-path-from-shell
It ensures that whenever emacs launches a shell to run something, it will use your local shell configuration including modifications made to $PATH
in .bashrc
它确保每当emacs启动一个shell来运行某些东西时,它都会使用您的本地shell配置,包括对.bashrc中的$PATH所做的修改
#1
2
This is what I suspect happened.
这就是我猜想发生的事情。
When you configure $PATH
, there are a few different ways to do it. One of the most common ways to do it is by adding it to your .bashrc
(or .zshrc
, .profile
, whatever) file in your home directory. However, when you do this, this does not actually set $PATH
anywhere else... only for the shell itself, and for programs runn from the shell.
当您配置$PATH时,有几种不同的方法。最常见的一种方法是将它添加到主目录中的.bashrc(或.zshrc、.profile)文件中。但是,当您这样做的时候,它实际上并没有在其他地方设置$PATH…只适用于外壳本身,以及从外壳中运行的程序。
You can still launch programs from your window manager (e.g. Gnome, Cinnamon, KDE), and these programs will inherit $PATH
not from your shell, but from your X login session.
您仍然可以从窗口管理器(例如Gnome、肉桂、KDE)启动程序,这些程序将从您的shell继承$PATH,而不是从您的X登录会话继承。
So after updating $PATH
in .bashrc
, Emacs will not see that path because it's not being launched from Bash.
因此,在.bashrc中更新$PATH之后,Emacs将看不到该路径,因为它没有从Bash启动。
ASCII Art Time
X Session $PATH=<original $PATH> + + +---------+ +--------+ v v Terminal Emacs $PATH=<original $PATH> + | v bash $PATH=/home/user/anaconda3/bin:$PATH
Solution #1: Change $PATH in .emacs
This is pretty easy. Just add a line to your .emacs
near the top like this:
这是非常容易的。在顶部添加一行,像这样:
(setenv "PATH" "/home/user/anaconda3/bin:/home/user/bin:/home/user/.local/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/usr/local/game")
This has some drawbacks... because now you're setting $PATH
in two different places, and these two places can get out of sync with each other (you can forget to update one when the other changes).
这有一些缺陷…因为现在您正在两个不同的位置设置$PATH,这两个位置可能会相互不同步(当其他位置发生更改时,您可能会忘记更新一个位置)。
This is the solution I use.
这是我使用的解决方案。
Solution #2: Configure Elpy to use your Python
Elpy, like most Emacs packages, is configurable. See: https://emacs.stackexchange.com/questions/16637/how-to-set-up-elpy-to-use-python3
与大多数Emacs包一样,Elpy是可配置的。参见:https://emacs.stackexchange.com/questions/16637/how-to-set-up-elpy-to-use-python3
You might be able to use M-x customize-group "elpy" or something like that, which means you don't have to edit your .emacs
by hand.
您可能可以使用M-x定制组“elpy”或类似的东西,这意味着您不必手动编辑。emacs。
Solution #3: Change $PATH for your X session
Depending on the specifics of your setup there are different ways to do this. I believe moving the $PATH
definitions from .bashrc
to .profile
may work, but it's been a while since I've done this.
根据您的设置的具体情况,有不同的方法来实现这一点。我相信将$PATH定义从.bashrc移动到.profile可能是可行的,但是我已经有一段时间没有这么做了。
#2
0
The accepted answer has a nice explanation of what's going on.
公认的答案对正在发生的事情有一个很好的解释。
For a quick solution, Install this package: exec-path-from-shell
要获得快速解决方案,请安装这个包:exec-path-from-shell
It ensures that whenever emacs launches a shell to run something, it will use your local shell configuration including modifications made to $PATH
in .bashrc
它确保每当emacs启动一个shell来运行某些东西时,它都会使用您的本地shell配置,包括对.bashrc中的$PATH所做的修改