我想安装pip。它应该支持Python 3,但它需要setuptools,这只适用于Python 2。
如何在python3中安装pip ?
我想安装pip。它应该支持Python 3,但它需要setuptools,这只适用于Python 2。
如何在python3中安装pip ?
当前回答
假设你在一个高度受限的计算机环境中(比如我自己),没有root权限或安装包的能力……
在这篇文章之前,我从来没有设置过Python+virtualenv的新/独立/原始/非根实例。为了做到这一点,我在谷歌上搜索了很多。
Decide if you are using python (python2) or python3 and set your PATH correctly. (I am strictly a python3 user.) All commands below can substitute python3 for python if you are python2 user. wget https://pypi.python.org/packages/source/v/virtualenv/virtualenv-x.y.z.tar.gz tar -xzvf virtualenv-x.y.z.tar.gz python3 virtualenv-x.y.z/virtualenv.py --python $(which python3) /path/to/new/virtualenv source /path/to/new/virtualenv/bin/activate Assumes you are using a Bourne-compatible shell, e.g., bash Brilliantly, this virtualenv package includes a standalone version of pip and setuptools that are auto-magically installed into each new virtualenv. This solves the chicken and egg problem. You may want to create an alias (or update your ~/.bashrc, etc.) for this final command to activate the python virtualenv during each login. It can be a pain to remember all these paths and commands. Check your version of python now: which python3 should give: /path/to/new/virtualenv/bin/python3 Check pip is also available in the virtualenv via which pip... should give: /path/to/new/virtualenv/bin/pip
然后……皮皮,皮皮,皮皮!
给python新手的最后一个提示:在开始时,您认为不需要virtualenv,但以后会很高兴拥有它。帮助开源/共享包的“假设”安装/升级场景。
裁判:https://virtualenv.pypa.io/en/latest/installation.html
其他回答
在Ubuntu 18.04或Ubuntu 20.04上安装Python的简单方法
步骤1:更新本地存储库:-
Sudo apt更新
第二步:安装支持软件
Sudo apt install build-essential zlib1g-dev libbncurses5 -dev libgdbm-dev libss3 -dev libssl-dev libreadline-dev libffi-dev wget
要下载最新版本的Python源代码,请导航到/ Python - Source -files目录并使用wget命令:-
mkdir python-source-files
步骤4:下载最新版本的Python源代码:-
wget https://www.python.org/ftp/python/3.7.5/Python-3.7.5.tgz
你可以修改python版本,只需要修改这个:-"3.7.5"和你想要的版本:
步骤5:解压压缩文件:-
柏油止咳饮料 或 焦油
步骤6:测试系统和优化Python:-
CD python-3.7.5或你的python版本。
步骤7:现在配置(使用——optimization选项可以使代码执行速度提高10-20%):-
. / configure——enable-optimizations
或者你也可以这样做,如果你面临ssl错误:-
. / configure——使用openssl
步骤8:安装第二个Python实例:-
Sudo做altinstall
建议使用“altinstall”方法。你的Ubuntu系统可能有依赖于Python 2.x的软件包。
OR
如果你想覆盖默认的Python安装/版本:-
Sudo make install"
步骤9:现在检查Python版本:-
python3——版本
步骤10:为python3安装pip只需执行以下命令:-
Sudo apt-get install python3-pip
更新2015-01-20:
根据https://pip.pypa.io/en/latest/installing.html,目前的方式是:
wget https://bootstrap.pypa.io/get-pip.py
python get-pip.py
我认为这适用于任何版本
最初的回答:
wget http://python-distribute.org/distribute_setup.py
python distribute_setup.py
easy_install pip
Python 3.4+和Python 2.7.9+
好消息!Python 3.4(2014年3月发布)随Pip一起发布。这是所有Python版本的最佳特性。它使每个人都可以使用社区丰富的图书馆。新手不再被设置的难度所排斥。随着包管理器的发布,Python加入了Ruby、Nodejs、Haskell、Perl、Go——几乎所有其他当代主流开源社区语言的行列。谢谢你,巨蟒。
当然,这并不意味着Python打包就解决了问题。这种经历仍然令人沮丧。Python是否有包/模块管理系统?
对于所有使用早期Python的人来说,这是可悲的。以下是手动说明。
Python≤2.7.8,Python≤3.3
请在https://stackoverflow.com/a/12476379/284795上遵循我的详细说明。本质上
官方说明
为了https://pip.pypa.io/en/stable/installing.html
下载get-pip.py,注意将其保存为.py文件而不是.txt。然后,从命令提示符中运行它。
python get-pip.py
您可能需要管理员命令提示符来完成此操作。按照http://technet.microsoft.com/en-us/library/cc947813 (v = ws.10) . aspx
对我来说,这将Pip安装在C:\Python27\Scripts\ Pip .exe。在您的计算机上找到pip.exe,然后添加它的文件夹(例如。C:\Python27\Scripts)到您的路径(开始/编辑环境变量)。现在您应该能够从命令行运行pip了。尝试安装一个包:
pip install httpie
好了(希望如此)!
假设你在一个高度受限的计算机环境中(比如我自己),没有root权限或安装包的能力……
在这篇文章之前,我从来没有设置过Python+virtualenv的新/独立/原始/非根实例。为了做到这一点,我在谷歌上搜索了很多。
Decide if you are using python (python2) or python3 and set your PATH correctly. (I am strictly a python3 user.) All commands below can substitute python3 for python if you are python2 user. wget https://pypi.python.org/packages/source/v/virtualenv/virtualenv-x.y.z.tar.gz tar -xzvf virtualenv-x.y.z.tar.gz python3 virtualenv-x.y.z/virtualenv.py --python $(which python3) /path/to/new/virtualenv source /path/to/new/virtualenv/bin/activate Assumes you are using a Bourne-compatible shell, e.g., bash Brilliantly, this virtualenv package includes a standalone version of pip and setuptools that are auto-magically installed into each new virtualenv. This solves the chicken and egg problem. You may want to create an alias (or update your ~/.bashrc, etc.) for this final command to activate the python virtualenv during each login. It can be a pain to remember all these paths and commands. Check your version of python now: which python3 should give: /path/to/new/virtualenv/bin/python3 Check pip is also available in the virtualenv via which pip... should give: /path/to/new/virtualenv/bin/pip
然后……皮皮,皮皮,皮皮!
给python新手的最后一个提示:在开始时,您认为不需要virtualenv,但以后会很高兴拥有它。帮助开源/共享包的“假设”安装/升级场景。
裁判:https://virtualenv.pypa.io/en/latest/installation.html
如果你使用命令"python get-pip.py",你应该有Python3的'pip'函数。但是,Python2的'pip'可能仍然存在。在我的例子中,我卸载了'pip',这将它从Python2中删除。
之后,我再次运行“python get-pip.py”。(确保'get-pip.py'保存在与Python3相同的文件夹中。)最后一步是将带有'pip'命令的目录添加到$PATH。这为我解决了问题。