在终端和intelliJ中更改python版本 [英] change python version in terminal and intelliJ
问题描述
短Q,
在mac OS sierra终端中,
In a mac OS sierra terminal,
如果我这样做:
whereis python
/usr/bin/python
然后,如果我这样做:
/ usr / bin / python
它打开python 2.10
Then if I do:
/usr/bin/python
it opens python 2.10
但是如果我执行
python
它会打开python 2.7.8。
,这个来自
/Library/Frameworks/Python.framework/Versions/2.7/bin/python
but if I execute
python
it opens python 2.7.8.
and this one comes from
/Library/Frameworks/Python.framework/Versions/2.7/bin/python
如何将默认python更改为指向python 2.7.8?在终端和智能中?
How do I change the default python to point to python 2.7.8? In the terminal and in intelliJ?
推荐答案
检查PATH环境变量
echo $PATH
你得到的python版本键入bare'python'将是在该目录列表中找到的第一个。
The python version you get when typing bare 'python' will be the first one found in that list of directories.
可以控制启动哪个python版本,例如,重新排列 PATH
中的条目或者在当前版本之前的位置添加符号链接到所需版本。
It is possible to control which python version is launched by, for example, rearranging the entries in PATH
or by adding a symbolic link to the desired version in a position before the current version.
然而,在同一台机器上管理多个python版本的一种比较流行的方法是使用 virtualenv 。当使用 pip
来安装/卸载特定python版本的软件包时,这将给您带来更少的麻烦。
However, a more popular way to manage multiple python versions on the same machine is to use virtualenv. This will give you much less headaches when using pip
to install/uninstall packages for particular python versions.
这篇关于在终端和intelliJ中更改python版本的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!