Hongyi Zhao <hongyi.z...@gmail.com> writes: > Hongyi Zhao <hongyi.z...@gmail.com> 于2019年10月8日周二 下午4:53写道: >> >> Cameron Simpson <c...@cskk.id.au> 于2019年10月8日周二 下午12:25写道: >> > >> > On 08Oct2019 02:49, Hongyi Zhao <hongyi.z...@gmail.com> wrote: >> > >On Tue, 08 Oct 2019 06:28:05 +0530, Pankaj Jangid wrote: >> > >> A very good use-case is when you have both, python2 and python3 >> > >> installed. >> > >> python2 -m pip install mod >> > >> python3 -m pip install mod >> > >> will install the package in the corresponding PYTHONPATH. >> > >> >> > > >> > >If so, why not just: >> > >pip2 install mod >> > >and using: >> > >pip3 install mod >> > >> > Because of the slight disconnect between "pip2" and "python2", etc. Do >> > you _know_ they both use the same Python install? With "pythonX -m pip" >> > you're using the same python executable which will be accessing what you >> > just installed. >> >> I use pyenv + pip, which will do the trick. > > And nowadays, the pyenv + vurtualenv + pip + pipenv is the suggested > env management method for python. > In this way, the pipenv will solve the version dependence of the > underlying tool chain and corresponding used packages/modules. >
Exactly. So the scripts will just work fine if you simply use ~import pip~ and work with it. Suppose you were writing bash scripts around python programs. Then what will be the behaviour of, pip2 install mod under a python3 environment. Similarly, there may be other commands specific to python2 and python3. All of them work flawlessly if you just replace python2 with python3. -- Regards, Pankaj Jangid -- https://mail.python.org/mailman/listinfo/python-list