How to use pip with python 2 & 3 installed? (OSX)
I am trying to get python 3 working on my OSX laptop.
I need to install requests for python 3, and it isn't working.
I think I've managed to get pip installed for both python 2.7 & python 3 however...
Whenever I use 'pip' it points to python2... I can't seem to access the pip for python 3?
python python-3.x pip pipenv
add a comment |
I am trying to get python 3 working on my OSX laptop.
I need to install requests for python 3, and it isn't working.
I think I've managed to get pip installed for both python 2.7 & python 3 however...
Whenever I use 'pip' it points to python2... I can't seem to access the pip for python 3?
python python-3.x pip pipenv
3
You havepip
andpip3
for Python-2.x and Python-3.x respectively.
– Willem Van Onsem
Nov 12 '18 at 19:00
add a comment |
I am trying to get python 3 working on my OSX laptop.
I need to install requests for python 3, and it isn't working.
I think I've managed to get pip installed for both python 2.7 & python 3 however...
Whenever I use 'pip' it points to python2... I can't seem to access the pip for python 3?
python python-3.x pip pipenv
I am trying to get python 3 working on my OSX laptop.
I need to install requests for python 3, and it isn't working.
I think I've managed to get pip installed for both python 2.7 & python 3 however...
Whenever I use 'pip' it points to python2... I can't seem to access the pip for python 3?
python python-3.x pip pipenv
python python-3.x pip pipenv
asked Nov 12 '18 at 18:59
Fire Dude
61
61
3
You havepip
andpip3
for Python-2.x and Python-3.x respectively.
– Willem Van Onsem
Nov 12 '18 at 19:00
add a comment |
3
You havepip
andpip3
for Python-2.x and Python-3.x respectively.
– Willem Van Onsem
Nov 12 '18 at 19:00
3
3
You have
pip
and pip3
for Python-2.x and Python-3.x respectively.– Willem Van Onsem
Nov 12 '18 at 19:00
You have
pip
and pip3
for Python-2.x and Python-3.x respectively.– Willem Van Onsem
Nov 12 '18 at 19:00
add a comment |
4 Answers
4
active
oldest
votes
In all likelihood, pip3
will be installed pointing to your Python 3 installation, so your use case is probably solvable by just switching from:
$ pip install foo
to:
$ pip3 install foo # Or pip3.7 install foo if you need to disambiguate further
That said, it can get kind of complicated when you have many different Python installs, where pip
/pip3
might have been installed pointing to a Python version that doesn't correspond to the python
/python3
you're using, which can be quite confusing.
If you know python
& python3
are the correct executable, just use it to invoke pip
on your behalf. It's fairly easy too, just check your version to be sure it's the one you expect (e.g. on my system):
$ python --version
Python 2.7.15rc1
$ python3 --version
Python 3.6.6
then use the appropriate one with -mpip
, a flag to run an installed module/package via the chosen Python as the "main" executable, bypassing the need for specifically versioned pip
executable entirely. So if you wanted to install foo
for Python 3.6 on my machine, you'd run:
$ python3 -mpip install foo
This is especially useful on Windows, where the pip
executables often either don't exist, or are not installed in the PATH
, so it's irritating to use them. Instead, use the Windows launcher that comes with any modern Python 3 version (but manages all Python versions on the machine), and is used to disambiguate among various versions. For example:
C:>; Installs foo for latest installed version of Python 3
C:>py -3 -mpip install foo
C:>; Installs foo for latest installed version of Python 2
C:>py -2 -mpip install foo
C:>; Installs foo for latest installed version of Python 3.6
C:>py -3.6 -mpip install foo
Essentially, any use of pip
can be replaced by executing the Python interpreter directly with the -mpip
option to run the pip
package as the "main" executable.
This trick applies to many other tools with dedicated launchers that are often not installed in the PATH
, particularly on Windows, and it makes updates easier too; my Windows shortcut for launching ipython3
never used a hardcoded path to the launcher (e.g. C:Program FilesPython36Scriptsipython3.exe
), instead using %WINDIR%py.exe -3 -mIPython
. In addition to being more portable (the shortcut "just works" on any Windows system with a semi-recent Python 3 install), it's self-updating; when I upgraded from 3.6 to 3.7, the shortcut didn't have to change at all (I had to run py -3 -mpip install ipython
again to get IPython reinstalled, but once I'd done that, the shortcut seamlessly began referring to the 3.7 install with no changes needed).
add a comment |
Run this command to find the python that is used before running pip: which python
. You can do the same idea to find which pip version is being run: which pip
You’ll need to create separate virtual environments in order to use different python versions and/or python dependencies. Use something like conda or venv to do this. Then, ensure that the desired python version virtual environment is activated prior to installing a new package with pip.
1
thanks, that is useful!
– Fire Dude
Nov 13 '18 at 20:55
add a comment |
To install requests
for python3
, use pip3 install requests
which is the pip
installer for Python 3 modules.
This guide has some further info on getting Python 3 working on a mac.
https://docs.python-guide.org/starting/install3/osx/
add a comment |
try to sudo apt-get update
first then sudo apt-get install python3-pip --fix-missing
Apt-get doesn't work on OSX?
– Fire Dude
Nov 13 '18 at 20:54
add a comment |
Your Answer
StackExchange.ifUsing("editor", function () {
StackExchange.using("externalEditor", function () {
StackExchange.using("snippets", function () {
StackExchange.snippets.init();
});
});
}, "code-snippets");
StackExchange.ready(function() {
var channelOptions = {
tags: "".split(" "),
id: "1"
};
initTagRenderer("".split(" "), "".split(" "), channelOptions);
StackExchange.using("externalEditor", function() {
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled) {
StackExchange.using("snippets", function() {
createEditor();
});
}
else {
createEditor();
}
});
function createEditor() {
StackExchange.prepareEditor({
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader: {
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
},
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
});
}
});
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53268470%2fhow-to-use-pip-with-python-2-3-installed-osx%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
4 Answers
4
active
oldest
votes
4 Answers
4
active
oldest
votes
active
oldest
votes
active
oldest
votes
In all likelihood, pip3
will be installed pointing to your Python 3 installation, so your use case is probably solvable by just switching from:
$ pip install foo
to:
$ pip3 install foo # Or pip3.7 install foo if you need to disambiguate further
That said, it can get kind of complicated when you have many different Python installs, where pip
/pip3
might have been installed pointing to a Python version that doesn't correspond to the python
/python3
you're using, which can be quite confusing.
If you know python
& python3
are the correct executable, just use it to invoke pip
on your behalf. It's fairly easy too, just check your version to be sure it's the one you expect (e.g. on my system):
$ python --version
Python 2.7.15rc1
$ python3 --version
Python 3.6.6
then use the appropriate one with -mpip
, a flag to run an installed module/package via the chosen Python as the "main" executable, bypassing the need for specifically versioned pip
executable entirely. So if you wanted to install foo
for Python 3.6 on my machine, you'd run:
$ python3 -mpip install foo
This is especially useful on Windows, where the pip
executables often either don't exist, or are not installed in the PATH
, so it's irritating to use them. Instead, use the Windows launcher that comes with any modern Python 3 version (but manages all Python versions on the machine), and is used to disambiguate among various versions. For example:
C:>; Installs foo for latest installed version of Python 3
C:>py -3 -mpip install foo
C:>; Installs foo for latest installed version of Python 2
C:>py -2 -mpip install foo
C:>; Installs foo for latest installed version of Python 3.6
C:>py -3.6 -mpip install foo
Essentially, any use of pip
can be replaced by executing the Python interpreter directly with the -mpip
option to run the pip
package as the "main" executable.
This trick applies to many other tools with dedicated launchers that are often not installed in the PATH
, particularly on Windows, and it makes updates easier too; my Windows shortcut for launching ipython3
never used a hardcoded path to the launcher (e.g. C:Program FilesPython36Scriptsipython3.exe
), instead using %WINDIR%py.exe -3 -mIPython
. In addition to being more portable (the shortcut "just works" on any Windows system with a semi-recent Python 3 install), it's self-updating; when I upgraded from 3.6 to 3.7, the shortcut didn't have to change at all (I had to run py -3 -mpip install ipython
again to get IPython reinstalled, but once I'd done that, the shortcut seamlessly began referring to the 3.7 install with no changes needed).
add a comment |
In all likelihood, pip3
will be installed pointing to your Python 3 installation, so your use case is probably solvable by just switching from:
$ pip install foo
to:
$ pip3 install foo # Or pip3.7 install foo if you need to disambiguate further
That said, it can get kind of complicated when you have many different Python installs, where pip
/pip3
might have been installed pointing to a Python version that doesn't correspond to the python
/python3
you're using, which can be quite confusing.
If you know python
& python3
are the correct executable, just use it to invoke pip
on your behalf. It's fairly easy too, just check your version to be sure it's the one you expect (e.g. on my system):
$ python --version
Python 2.7.15rc1
$ python3 --version
Python 3.6.6
then use the appropriate one with -mpip
, a flag to run an installed module/package via the chosen Python as the "main" executable, bypassing the need for specifically versioned pip
executable entirely. So if you wanted to install foo
for Python 3.6 on my machine, you'd run:
$ python3 -mpip install foo
This is especially useful on Windows, where the pip
executables often either don't exist, or are not installed in the PATH
, so it's irritating to use them. Instead, use the Windows launcher that comes with any modern Python 3 version (but manages all Python versions on the machine), and is used to disambiguate among various versions. For example:
C:>; Installs foo for latest installed version of Python 3
C:>py -3 -mpip install foo
C:>; Installs foo for latest installed version of Python 2
C:>py -2 -mpip install foo
C:>; Installs foo for latest installed version of Python 3.6
C:>py -3.6 -mpip install foo
Essentially, any use of pip
can be replaced by executing the Python interpreter directly with the -mpip
option to run the pip
package as the "main" executable.
This trick applies to many other tools with dedicated launchers that are often not installed in the PATH
, particularly on Windows, and it makes updates easier too; my Windows shortcut for launching ipython3
never used a hardcoded path to the launcher (e.g. C:Program FilesPython36Scriptsipython3.exe
), instead using %WINDIR%py.exe -3 -mIPython
. In addition to being more portable (the shortcut "just works" on any Windows system with a semi-recent Python 3 install), it's self-updating; when I upgraded from 3.6 to 3.7, the shortcut didn't have to change at all (I had to run py -3 -mpip install ipython
again to get IPython reinstalled, but once I'd done that, the shortcut seamlessly began referring to the 3.7 install with no changes needed).
add a comment |
In all likelihood, pip3
will be installed pointing to your Python 3 installation, so your use case is probably solvable by just switching from:
$ pip install foo
to:
$ pip3 install foo # Or pip3.7 install foo if you need to disambiguate further
That said, it can get kind of complicated when you have many different Python installs, where pip
/pip3
might have been installed pointing to a Python version that doesn't correspond to the python
/python3
you're using, which can be quite confusing.
If you know python
& python3
are the correct executable, just use it to invoke pip
on your behalf. It's fairly easy too, just check your version to be sure it's the one you expect (e.g. on my system):
$ python --version
Python 2.7.15rc1
$ python3 --version
Python 3.6.6
then use the appropriate one with -mpip
, a flag to run an installed module/package via the chosen Python as the "main" executable, bypassing the need for specifically versioned pip
executable entirely. So if you wanted to install foo
for Python 3.6 on my machine, you'd run:
$ python3 -mpip install foo
This is especially useful on Windows, where the pip
executables often either don't exist, or are not installed in the PATH
, so it's irritating to use them. Instead, use the Windows launcher that comes with any modern Python 3 version (but manages all Python versions on the machine), and is used to disambiguate among various versions. For example:
C:>; Installs foo for latest installed version of Python 3
C:>py -3 -mpip install foo
C:>; Installs foo for latest installed version of Python 2
C:>py -2 -mpip install foo
C:>; Installs foo for latest installed version of Python 3.6
C:>py -3.6 -mpip install foo
Essentially, any use of pip
can be replaced by executing the Python interpreter directly with the -mpip
option to run the pip
package as the "main" executable.
This trick applies to many other tools with dedicated launchers that are often not installed in the PATH
, particularly on Windows, and it makes updates easier too; my Windows shortcut for launching ipython3
never used a hardcoded path to the launcher (e.g. C:Program FilesPython36Scriptsipython3.exe
), instead using %WINDIR%py.exe -3 -mIPython
. In addition to being more portable (the shortcut "just works" on any Windows system with a semi-recent Python 3 install), it's self-updating; when I upgraded from 3.6 to 3.7, the shortcut didn't have to change at all (I had to run py -3 -mpip install ipython
again to get IPython reinstalled, but once I'd done that, the shortcut seamlessly began referring to the 3.7 install with no changes needed).
In all likelihood, pip3
will be installed pointing to your Python 3 installation, so your use case is probably solvable by just switching from:
$ pip install foo
to:
$ pip3 install foo # Or pip3.7 install foo if you need to disambiguate further
That said, it can get kind of complicated when you have many different Python installs, where pip
/pip3
might have been installed pointing to a Python version that doesn't correspond to the python
/python3
you're using, which can be quite confusing.
If you know python
& python3
are the correct executable, just use it to invoke pip
on your behalf. It's fairly easy too, just check your version to be sure it's the one you expect (e.g. on my system):
$ python --version
Python 2.7.15rc1
$ python3 --version
Python 3.6.6
then use the appropriate one with -mpip
, a flag to run an installed module/package via the chosen Python as the "main" executable, bypassing the need for specifically versioned pip
executable entirely. So if you wanted to install foo
for Python 3.6 on my machine, you'd run:
$ python3 -mpip install foo
This is especially useful on Windows, where the pip
executables often either don't exist, or are not installed in the PATH
, so it's irritating to use them. Instead, use the Windows launcher that comes with any modern Python 3 version (but manages all Python versions on the machine), and is used to disambiguate among various versions. For example:
C:>; Installs foo for latest installed version of Python 3
C:>py -3 -mpip install foo
C:>; Installs foo for latest installed version of Python 2
C:>py -2 -mpip install foo
C:>; Installs foo for latest installed version of Python 3.6
C:>py -3.6 -mpip install foo
Essentially, any use of pip
can be replaced by executing the Python interpreter directly with the -mpip
option to run the pip
package as the "main" executable.
This trick applies to many other tools with dedicated launchers that are often not installed in the PATH
, particularly on Windows, and it makes updates easier too; my Windows shortcut for launching ipython3
never used a hardcoded path to the launcher (e.g. C:Program FilesPython36Scriptsipython3.exe
), instead using %WINDIR%py.exe -3 -mIPython
. In addition to being more portable (the shortcut "just works" on any Windows system with a semi-recent Python 3 install), it's self-updating; when I upgraded from 3.6 to 3.7, the shortcut didn't have to change at all (I had to run py -3 -mpip install ipython
again to get IPython reinstalled, but once I'd done that, the shortcut seamlessly began referring to the 3.7 install with no changes needed).
edited Nov 12 '18 at 19:30
answered Nov 12 '18 at 19:23
ShadowRanger
58k45495
58k45495
add a comment |
add a comment |
Run this command to find the python that is used before running pip: which python
. You can do the same idea to find which pip version is being run: which pip
You’ll need to create separate virtual environments in order to use different python versions and/or python dependencies. Use something like conda or venv to do this. Then, ensure that the desired python version virtual environment is activated prior to installing a new package with pip.
1
thanks, that is useful!
– Fire Dude
Nov 13 '18 at 20:55
add a comment |
Run this command to find the python that is used before running pip: which python
. You can do the same idea to find which pip version is being run: which pip
You’ll need to create separate virtual environments in order to use different python versions and/or python dependencies. Use something like conda or venv to do this. Then, ensure that the desired python version virtual environment is activated prior to installing a new package with pip.
1
thanks, that is useful!
– Fire Dude
Nov 13 '18 at 20:55
add a comment |
Run this command to find the python that is used before running pip: which python
. You can do the same idea to find which pip version is being run: which pip
You’ll need to create separate virtual environments in order to use different python versions and/or python dependencies. Use something like conda or venv to do this. Then, ensure that the desired python version virtual environment is activated prior to installing a new package with pip.
Run this command to find the python that is used before running pip: which python
. You can do the same idea to find which pip version is being run: which pip
You’ll need to create separate virtual environments in order to use different python versions and/or python dependencies. Use something like conda or venv to do this. Then, ensure that the desired python version virtual environment is activated prior to installing a new package with pip.
answered Nov 12 '18 at 19:03
Riley Steele Parsons
23116
23116
1
thanks, that is useful!
– Fire Dude
Nov 13 '18 at 20:55
add a comment |
1
thanks, that is useful!
– Fire Dude
Nov 13 '18 at 20:55
1
1
thanks, that is useful!
– Fire Dude
Nov 13 '18 at 20:55
thanks, that is useful!
– Fire Dude
Nov 13 '18 at 20:55
add a comment |
To install requests
for python3
, use pip3 install requests
which is the pip
installer for Python 3 modules.
This guide has some further info on getting Python 3 working on a mac.
https://docs.python-guide.org/starting/install3/osx/
add a comment |
To install requests
for python3
, use pip3 install requests
which is the pip
installer for Python 3 modules.
This guide has some further info on getting Python 3 working on a mac.
https://docs.python-guide.org/starting/install3/osx/
add a comment |
To install requests
for python3
, use pip3 install requests
which is the pip
installer for Python 3 modules.
This guide has some further info on getting Python 3 working on a mac.
https://docs.python-guide.org/starting/install3/osx/
To install requests
for python3
, use pip3 install requests
which is the pip
installer for Python 3 modules.
This guide has some further info on getting Python 3 working on a mac.
https://docs.python-guide.org/starting/install3/osx/
answered Nov 12 '18 at 19:26
Dmitriy Khaykin
4,85811530
4,85811530
add a comment |
add a comment |
try to sudo apt-get update
first then sudo apt-get install python3-pip --fix-missing
Apt-get doesn't work on OSX?
– Fire Dude
Nov 13 '18 at 20:54
add a comment |
try to sudo apt-get update
first then sudo apt-get install python3-pip --fix-missing
Apt-get doesn't work on OSX?
– Fire Dude
Nov 13 '18 at 20:54
add a comment |
try to sudo apt-get update
first then sudo apt-get install python3-pip --fix-missing
try to sudo apt-get update
first then sudo apt-get install python3-pip --fix-missing
answered Nov 13 '18 at 4:40
Ocabafox
113
113
Apt-get doesn't work on OSX?
– Fire Dude
Nov 13 '18 at 20:54
add a comment |
Apt-get doesn't work on OSX?
– Fire Dude
Nov 13 '18 at 20:54
Apt-get doesn't work on OSX?
– Fire Dude
Nov 13 '18 at 20:54
Apt-get doesn't work on OSX?
– Fire Dude
Nov 13 '18 at 20:54
add a comment |
Thanks for contributing an answer to Stack Overflow!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Some of your past answers have not been well-received, and you're in danger of being blocked from answering.
Please pay close attention to the following guidance:
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53268470%2fhow-to-use-pip-with-python-2-3-installed-osx%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
3
You have
pip
andpip3
for Python-2.x and Python-3.x respectively.– Willem Van Onsem
Nov 12 '18 at 19:00