Reputation: 196
I have been using Python 2.7 for a while now and installing packages using pip install
without any issue. I just started using python 3 for a certain code and realized how confusing having different versions of Python can get.
I have Fedora 25, the default Python version is 2.7.13 and the default Python 3 version is Python 3.5.3,
I want to be able to use python 2.7 and python 3, my general question is:
What are the best practices when installing packages for both Python 2 and Python 3 on one machine?
As I mentioned using pip install
in Python 2.7 works fine, but what about Python 3? I can:
pip3 install
python3 -m pip install
Which one should I use and how does it affect the python 2 version of the module? pip3 is not installed on Fedora 25, which raises a new question: how should I install it? as I understand I can:
dnf install python3-pip
(it is unclear if that actually works when pip for Python 2.7 is installed)python3 get-pip.py
Finally, would it be a good idea to create a Python 2 and a Python 3 virtual environment to address this issue?
From what I have read on the internet there does not seem to be a clear consensus on these questions, I hope this thread will clarify.
Upvotes: 2
Views: 203
Reputation: 94492
pip3 install
and python3 -m pip install
— both work perfectly and don't have any impact on Python 2. You can have as many Pythons in your system as you want; I for one have Python 2.7, 3.4, 3.5 and 3.6. To distinguish different versions of pip I use versioned names: pip3.4 install
.
And of course I use virtual environments and virtualenvwrapper quite intensively.
Upvotes: 3