How to install Python 3 on mac? [duplicate] - python

This question already has answers here:
How to make Mac OS use the python installed by Homebrew
(6 answers)
How to specify location of Brew install of Python?
(2 answers)
Closed 18 days ago.
I am new here and I desperately need help with installing Python 3 on mac. I tried other answers but it didn't work... so I run brew install python and it shows Warning: python#3.10 3.10.9 is already installed and up-to-date.but when I run python --version, it shows Python 2.7.18
Question: How to swtich python 2.7 to python 3.10? Appreciate your help!!!
I have tried the command in Learn To Setup Python 3 As A Default On your Mac
when I run which python3, it returns /usr/bin/python3, and then I run echo alias python=/usr/bin/python3 >> ~/.zshrc and I got Permission denied

Instead of using python, try python3

Related

Pip installs packages into the python 3.9 folder, but the executable commands are in the python 3.8 [duplicate]

This question already has answers here:
Dealing with multiple Python versions and PIP?
(28 answers)
Closed 1 year ago.
I have both python 3.8 and 3.9 on my Mac. when I install a new package by pip3 install ..., the package will go to the python 3.9 folder, but apparently the executable commands to run in terminal is in python 3.8 folder, so even though I installed a package, I cannot run the command lines come with it.
I guess I have to somehow point the path of python to version 3.9?
Can somebody help me to fix this?
Try which python3.9 to definitively determine if and where Python 3.9 lives on your path. Then run python3.9 -m pip install … to ensure that the command gets executed against the Python 3.9 interpreter.

Installing python package for a particular version [duplicate]

This question already has answers here:
Using pip on Windows installed with both python 2.7 and 3.5
(8 answers)
Closed 1 year ago.
In the cmd when I type where pip I get the following results
F:\python39\Scripts\pip.exe
F:\python38\Scripts\pip.exe
F:\miniconda_pf\Scripts\pip.exe
Now I would like to install a package, let's say in the python38 folder, how can I do that?
It seems like you're using conda, so you can use conda activate [environment name] and use install pip modules.

Cannot run PIP commands from windows command prompt [duplicate]

This question already has answers here:
Why does "pip install" inside Python raise a SyntaxError?
(7 answers)
Closed 2 years ago.
I am trying to install some packages from the command prompt on my windows OS. I tried the steps given in the answer here but they don't seem to work for me. I can use the spyder IDE to install the package and get on with it but I want to know how to do it from Command line. I am getting this syntax error.
Did you install pip? Check it with using pip --version
If not, please install and after that, it should work with using:
pip install django

Changing pip directory after Python3.7 update [duplicate]

This question already has answers here:
How to run pip from different versions of python using the python command?
(4 answers)
Closed 4 years ago.
I have installed Python 3.7 I can use Python 3.7 by typing python3 command in terminal.
However if i type pip --version or pip3 --version it prints pip 18.1 from /usr/local/lib/python3.5/dist-packages/pip (python 3.5) in either case. So i cannot install packages to use with Python3.7
How can i set pip3 path and Python version to use it with Python3.7 ?
BTW i use Raspbian Stretch as OS.
Your path is probably not properly configured.
In general, it's best to leave system Python version untouched to avoid breaking things.
I would recommend using pyenv to manage and easily switch Python versions. It can easily work with virtual environments as well, or even as a substitute.
Install from here: https://github.com/pyenv/pyenv#installation

Invalid Syntax in Python for -m pip install (...) tried everything [duplicate]

This question already has answers here:
pip not working on windows python 2.7.9
(8 answers)
Closed 4 years ago.
I know there's a post like this, but I can't find the answer yet :S
I installed the last version of Python (3.7) and it's already come with pip right? I tried everything on CMD in intention to install libraries but everytime i got "Invalid Syntax".
py -m pip install ndjson;
python -m pip install ndjson;
pip install ndjson;
python.exe -m pip install ndjson;
even python --version got invalid syntax.
someone help me?
my windows is 64 bits..
EDIT:
enter image description here
You are in your Python interpreter rather than the terminal.
Open a new terminal and try pip install ndjson again.
Just so you know, if you see >>> at the start of your terminal, you're in the Python interpreter. You can't run pip commands from the Python interpreter; you can only run them from the terminal.
To exit the interpreter you can type quit() (or hit control D in some systems), which will bring you back to your terminal.

Categories