[英]Python and pip installation on Mac don't show version?
On Mac OS.在 Mac 操作系统上。
Downloaded the Python
from their website.从他们的网站下载了
Python
。
Python -V
return Python 2.7.16
, and python3 -V
return Python 3.9.4
Python -V
返回Python 2.7.16
和python3 -V
返回Python 3.9.4
Installed pip
with: python3 get-pip.py
, got Successfully installed pip-21.0.1
安装
pip
: python3 get-pip.py
, Successfully installed pip-21.0.1
But when I run pip -V
I get File "/usr/local/bin/pip", line 1.... SyntaxError: invalid syntax
但是当我运行
pip -V
我得到File "/usr/local/bin/pip", line 1.... SyntaxError: invalid syntax
After reading here a lot, i could not understand (in simple words for dumbs):在这里阅读了很多之后,我无法理解(对于笨蛋来说简单的话):
pip
version if it's installed ?pip
版本,为什么我无法获得它? Use pip as a module instead使用 pip 作为模块代替
% python3 -m pip --version
pip 21.0.1 from /usr/local/lib/python3.9/site-packages/pip (python 3.9)
Anyone who's interested, what i had to do is to任何有兴趣的人,我要做的就是
python3 -m venv env
(this create virtual environment of python3 inside project)python3 -m venv env
(这会在项目中创建 python3 的虚拟环境)source env/bin/activate
activate it.source env/bin/activate
激活它。pip --version
or python --version
will return the right results.pip --version
或python --version
将返回正确的结果。 From my basic knowledge i understand that the mac is using python2 which we don't want to interrupt, so we install python3 and create a 'virtual environment' for it inside our project folder, once its in, we can install all other things.根据我的基本知识,我知道mac正在使用我们不想中断的python2,所以我们安装python3并在我们的项目文件夹中为它创建一个“虚拟环境”,一旦它进入,我们就可以安装所有其他东西。
to deactivate (stop the virtual env) we run deactivate
停用(停止虚拟环境)我们运行
deactivate
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.