简体   繁体   English

为什么我的Python脚本文件夹中有多个pip版本?

[英]why are there multiple pip versions in my Python scripts folder?

I have a variety of different Python versions installed on my Windows system- a 2.7 version, a 3.5 version, and a 3.6 version (there are a bunch of different packages that only work with one version, or are too buggy in the 3.6 version, etc.). 我在Windows系统上安装了各种不同的Python版本-2.7版本,3.5版本和3.6版本(有很多不同的软件包只能使用一个版本,或者在3.6版本中存在太多错误,等等。)。

Long story short, I'm trying to keep my all my pip s and python.exe s in order. 长话短说,我试图使我所有的pippython.exe保持秩序。 I've added my C:/Python35 and C:/Python36 and their Scripts folders to my path, but I also want to make sure that I am using the right pip from my command line (for example, I don't want to pip install pyinstaller to the 3.6 version, since Python 3.6 doesn't play well with pyinstaller as of right now. 我已经在路径中添加了C:/Python35C:/Python36及其Scripts文件夹,但是我还想确保自己在命令行中使用了正确的pip (例如,我不想pip install pyinstaller到3.6版本,因为pip install pyinstaller ,Python 3.6在pyinstaller中不能很好地pyinstaller

I see that inside my Python3x/Scripts/ folder, there are three different pip s available: pip , pip3.5 , and pip3 . 我看到我的内Python3x/Scripts/文件夹中,有三种不同的pip的可用: pippip3.5pip3 在此处输入图片说明

So whenever I want to install a module for 3.5 , I plan to issue the following command pip3.5 install package_name . 因此,每当我想为3.5安装模块时,我计划发出以下命令pip3.5 install package_name Whenever I want to install something for 3.6, I'd use pip or pip3 . 每当我想为3.6安装东西时,我都会使用pippip3 Seems like a decent enough plan to me. 对我来说似乎是一个足够体面的计划。

However, can anyone confirm if the three pip s are all the same executable? 但是,任何人都可以确认三个pip是否都是相同的可执行文件吗? If so, I'd like to delete pip and pip3 so that I don't accidentally confuse it with my Python 3.6 pip - is this acceptable practice or am I missing something? 如果是这样,我想删除pippip3以免将其与Python 3.6 pip混淆,这是可以接受的做法,还是我错过了一些东西? This SO post provides some insights but doesn't explain why there's multiple pip s in the same folder. 这篇SO帖子提供了一些见解,但没有解释为什么同一文件夹中有多pip Also, why are three separate pip s provided? 另外,为什么要提供三个单独的pip Is it simply for convenience from the command line? 是否只是为了从命令行方便起见?

Within the same python installation all the different pip files you find should be the same executable, there is the multiple versions simply to help keep everything in order if there are multiple installs of python on a single computer. 在同一python安装中,您发现的所有不同pip文件都应是相同的可执行文件,如果单个计算机上有多个python安装,则存在多个版本只是为了帮助使所有内容保持顺序。

I personally only have the main version of python I use for development set to my PATH variable on my windows laptop and then if I need to do anything to a different python I instead link directly to the necessary file with something like C:\\Python36\\Scripts\\pip3 install natsort but that is simply personal preference and my way of organizing. 我个人只有用于Windows开发的python主版本设置为Windows笔记本电脑上的PATH变量,然后如果我需要对其他python做任何事情,而是直接使用C:\\Python36\\Scripts\\pip3 install natsort链接到所需文件C:\\Python36\\Scripts\\pip3 install natsort但这只是个人喜好和我的组织方式。

If you do have them all on path you can then simply call out pip3.6 install <package name> or whatever python version you are using 如果您确实将它们全部放在路径上,则可以简单地调用pip3.6 install <package name>或您使用的任何python版本

The difference between them is that each one install the package in its own folder, for example if i type pip install Django, it will be placed for python 2 version, but is a little bit complex when you have multiple version of python3 like you showed, the solution: Don't delete the files and makevirtualenv when you're working, that avoid problems. 它们之间的区别是每个软件包都将软件包安装在其自己的文件夹中,例如,如果我键入pip install Django,它将被放置在python 2版本中,但是当您有多个python3版本时(如您所示)会有点复杂解决方案:工作时不要删除文件和makevirtualenv,这样可以避免出现问题。

This prevents dependency issues with different versions of Python. 这样可以防止不同版本的Python出现依赖性问题。 You also check out virtualenvwrapper which is a convenient way to manage your virtual environments 您还可以签出virtualenvwrapper,这是管理虚拟环境的便捷方法

If you want to manage the version with virtualenv 如果要使用virtualenv管理版本

virtualenv python2_project -p usr/bin/python2.7
virtualenv p35_project -p usr/bin/python3.5
virtualenv p3x_project -p usr/bin/python3.x

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM