I am new to python. I am using python 3.5 on mac os x el capitan. I tried using the command 'pip install requests' in the python interpreter IDLE. But it throws invalid 'syntax error'.
I read about installing modules is only possible in the command line. So I moved to TERMINAL, but no command is working here also. (I tried 'python -m pip install requests')
I read that mac os x comes with python 2.7 already installed and I ran 'easy_install pip' but it also works on the 2.7 version. Then there's discussion about the PATH settings also.
Can please anybody explain to me how I can use my current version in TERMINAL window and what is the PATH scenario.
I am familiar with the environment variable settings and adding pythonpath in windows but not on mac.
Here is what you should do.
Use homebrew to install python 2.7 and 3.5 in a virtual environment.
pip install virtualenv
Then make a directory called virtualenvs
in your root folder and add local files with.
cd virtualenvs
virtualenv venv
activate a virtualenv with source ~/virtualenvs/bin/activate
Then use pip to install brew in this virtualenv pip install brew
Then install python 2.7 as python and python 3 as python3:
brew update
brew install python
brew install python3
Then you can use python and python3 and not have to worry about the local install.
Then to run a file python3 filename.py
Followed this guide. https://docs.python.org/3/using/mac.html
Found python3.5 in usr/local/bin instead of the default usr/bin where the default 2.7 exists.
The 3.5 Package automatically genrates an alias for itself that is python3.5 for use in terminal.
Ran the command 'python3.5 -m pip install requests' and everything went good.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With