python 版本 (conda -forge)
我正在使用 18.04 Ubuntu 和 Anaconda。最近我尝试在基础环境中通过 conda-forge 通道安装 OpenCV。我没有特意安装任何Python版本,也没有在基础环境中使用任何pip命令。现在,在基础环境中,如果只执行 python,我会得到与系统版本相同的 python 版本,如果执行 python3,我会得到 conda-forge 安装的版本。请参考屏幕截图。 Python_on_Conda_base
我想知道 python 和 python3 命令之间有什么区别?我应该做什么记住?基本上我更喜欢Python 3.7.5版本 所以,只有Python3使用了不同的版本。那么,问题是当我使用 python3 some_script.py 时应该注意什么?这个 2 版本的优点和缺点是什么?
到目前为止,我没有遇到任何问题,但从 Anaconda 中删除了 conda-forge 通道以避免任何冲突。有什么想法吗? 发布这个问题后,我注意到 python --version
命令在 Conda 基础环境和 Ubuntu 终端(Conda 外部)上给出了 Python 3.7.5
I am using 18.04 Ubuntu with Anaconda.Recently i have trying to install OpenCV through conda-forge channel in the base environment. I did not install purposely any Python version and did not use any pip command either in base environment. Now, in the base environment, if execute just python, i get the same python version as system version and if execute python3 , i get the version installed by conda-forge. Please refer the screen shot. Python_on_Conda_base
I would like to know what is difference between python and python3 command?.What is should i keep in mind? basically i prefer the version 3.7.5 Python
.So, only the Python3 has uses different version. So, question what i should take note when i using python3 some_script.py
? what is pros and cons of having this 2 version?
So far,i did not face any issues, but removed the conda-forge channel from Anaconda to avoid any conflicts. Any thoughts?
After posting this question, i have noticed python --version
command gives Python 3.7.5
on Conda base environment and Ubuntu terminal (outside Conda)
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您很可能已为
python
设置了一个别名以指向 python3 二进制文件。通过输入
type python
来检查这一点,这可能会给你这里的关键是
which
不会检测到别名,正如你在评论中透露的那样,你的which python
从 conda 基本环境返回正确的 python 版本,这使得别名成为最有可能的解释,因为可以排除PATH
问题。如果上述命令确实显示了别名,请检查您的
.bashrc
或您可能已修改的行alias python=...
的类似文件。删除它,重新启动终端,一切都应该正常工作You most likely have set an alias for
python
to point to the python3 binary.Check this by typing
type python
, which will probably give youThe crux here is that an alias will not be detected by
which
and as you revealed in the comments yourwhich python
returns the correct python version from your conda base environment, which makes an alias the most likely explanation, asPATH
issues can be ruled out.If above command does indeed reveal an alias, then check you
.bashrc
or similar file that you might have modified for a linealias python=...
. Delete it, restart your terminal and everything should work normally