I had python 2.6 and I downloaded Django. I found that python 2.6 throws errors when trying to run django, so I downloaded python 2.7. Now, typing python in the terminal runs 2.7 but the django library isn't in the 2.7 folder. So I uninstalled django using:
sudo pip uninstall django
and that worked just fine. When i used the command:
sudo pip install django
it installed into the python 2.6 instead of python 2.7.
How can I install django into python 2.7 instead of python 2.6?
(I am running a MacBook Pro on 1.6, and I was told to not uninstall the base version of python because so many of the systems use 2.6)
You need to install pip for python2.7. If it's installed, you should be able to see it using which pip-2.7.
It's better not to touch system python. Use homebrew to install your own.
The problem is that you are running pip from your default Python installation (2.6), read this: How to run multiple python version on Windows, maybe answers give you how to solve in your OS X.
You can view the version of your default Python installation by executing python -V, there is a way to specify which version to use when you execute python, in Linux you can create an alias (alias python=python2.7) in your $HOME/.bash_profile, OS X must have something similar, then install pip using your preferred version.
BTW, It's recommended to use virtualenv
Related
I was trying to install Python 3.7 using homebrew with "brew install python". When I check the version of python installed, I get python 2.7.10. Anyone know how to fix this?
Most likely you need to call python 3.7 commands with
python3
and install packages with
pip3
as well, also check your $PATH configuration, as is it usually takes the OSx python as default in Macs
I am attempting to install django framework using pip install -e django/, however, it requires Python 3.5+. Mac OSX by default comes with Python 2.7 so I have installed Python 3.6.5 from the python website.
I have confirmed the latest version of Python is installed through python3 .
I am still unable to install Django likely because Python 2.7 is also installed and seen first by pip.
Is it necessary to remove Python 2.7 from my system or can I modify PYTHON_HOME to achieve what I would like to do?
You can install to python 3 using
pip3 install django
python3 -m pip install django
As abarnert says in the comments, you shouldn't remove the Python 2.7 installation or try to set Python 3 to be the default.
It's good practice to use a virtual environment. Since you're using Python 3 you could use pipenv. Once the Python 3 virtual environment is activated, python will use the python 3 from the virtual environment.
Python newbie here. I just bought a new Mac Book Pro (switched from Windows) and Python 2.7 is already installed on it. I want to install 3.6 side by side and choose between the two versions. I found a great tutorial located here http://joebergantine.com/articles/installing-python-2-and-python-3-alongside-each-ot/ but I'm confused on one of the command line operations. Under Python 2 Installation it says:
Install Python 2 from the latest Python.org package. This allows you to run python2 and pip. After this installation Python 2.x will be accessible at /Library/Frameworks/Python.framework/Versions/2.7/bin/.
Once the Python 2 package is installed, install virtualenv for Python
2 for the User only. When specifying the User installation, Python
packages are then accessible at ~/Library/Python/2.7/bin. Specifying
the User installation doesn't automatically add virtualenv to the
system path which we will do manually in the next step via an alias.
This is what allows Python3 and Python2 to run alongside each other:
$ pip install --user virtualenv
Do I have to be in the ~/Library/Python/2.7/bin directory when I run this command or the /Library/Frameworks/Python.framework/Versions/2.7/bin/ directory? I'm confused because I don't know where the former directory is coming from.
Why not using pip for python 2.7 and pip3 for python 3.6?
If it says pip3 is not installed you can use sudo apt-get install pip3
then you can use pip3 for python 3.6 and pip for python2.7 for installing packages for respective versions
I faced the exact error, in the exact situation about 2 years ago. The solution to your issue is pyenv. I was able to run multiple versions of python inside different folders of the same directory. It truly was a very nice solution.
Hope this helps.
I'm using a third-party Python package that supports Python 3.5, but not 3.6. I've got Python 2.7 installed from my OS vendor (it's a Mac), and Python 3.6 installed through homebrew.
What's the best way for me to install 3.5 and configure IntelliJ IDEA (using its Python plugin, so it's basically equivalent to PyCharm) to use it?
You can install as many Python distributions as you want and they all located in /Library/Frameworks/Python.framework/Versions. However, pip3 will only be linked to the last python distribution you installed, not the latest. For example, in my case, my pip3 is the module in python3.5 because I installed it after 3.6. If you want to use a package for a specific version, run $ python3.x -m package. python3.6 -m pip install, for example.
I am using a Python on a Mac and I know that Python 2 comes preinstalled on the system (and in fact usable through Terminal). Is there a way to make it so Terminal can run Python 3? Can/should you set this as a default? I know changing the default settings for Python version usage could break your system so should I just install Python 3 and then use it through its launch icon instead?
Use can use python version management tool
https://github.com/yyuu/pyenv
Package manager:
pip3 install something
Interpreter:
python3
You can use python 3 in terminal after you have python 3 installed. Every time you run a command type python3 instead of python if you are using pip to install modules you can do this:
But you must have pip installed for python 3
$ python3 -m pip install something
Best option is to install Python through Anaconda. This allows easy management and much more. You can have virtual environments having different Python versions as well as different modules installed.
as usual in Mac python 2.7 is already installed, however if you installed python 3+
then you can just type in terminal: python3
so that you can use the newer version that you installed.
if you want to use python 2.7 then just type: python