I am currently running RHEL 6.6. This has python 2.6.6 pre-installed and is the default. I installed python 2.7 using the altinstall method. The default python is still 2.6.6. I'm trying to install the python-devel packages using yum which only runs with root. However when I run yum install python-devel as root it installs the packages to python 2.6.6.
Is there a way to get yum to install packages using the alt python install?
You may want to use the Python 2.7 version that is available as part of "Software Collections". This is installed along side the original 2.6 and doesn't try to replace it (and is included in nearly all RHEL subscriptions.) See info here:
Introduction: http://developers.redhat.com/products/softwarecollections/overview/
List of available components including Python 2.7: https://access.redhat.com/documentation/en-US/Red_Hat_Software_Collections/2/html/2.0_Release_Notes/chap-RHSCL.html#sect-RHSCL-Features
It's still a yum install, but with an extra command or two. You can start with this Get Started guide for Python 3.4 (http://developers.redhat.com/products/softwarecollections/get-started-rhel6-python/) but swap out the Python versions in steps 2 and 3.
Related
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:
use pip3 install
use 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:
use dnf install python3-pip (it is unclear if that actually works when pip for Python 2.7 is installed)
use 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.
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.
Being new to Python, I'd love to clear up a few points that I couldn't get from reading various articles and tutorials.
After using Homebrew to install Python3, I noticed that it had installed both Python3 and Python3.4. I was also a little surprised that there are now three versions of pip on my machine too; pip, pip3 and pip3.4.
I created a new virtualenv and told it to use Python3, using the following command:
virtualenv -p /usr/local/bin/python3 mysite
I was also surprised that the version of Python that it installed in my VM was 3.4.
Is it safe to have these multiple version of Python and Pip hanging around on my machine?
Am I right to assume that I should take extra care to use the matching version of pip with Python, for example, pip3.4 with Python3.4?
Yes, it is safe. Python uses this naming like python3.4, python3.5 etc to differentiate between releases. python3 is a symbolic link to the current python3.x version. Pip follows the same convention.
If you're using python3.4 explicitly, you should be using pip3.4 specifically as well. Otherwise, just use python3 and pip3. For Python 2, you can simply use python (which, unless you installed the Homebrew version as well), will be the system Python), and ditto for pip. python2.7 and pip2.7 may also work.
In general, to find out which Python version goes with which pip you're using, try:
pip --version
and you'll see the Python included in the result.
No need to worried about if you have multiple version of Python and Pip installed. just check your version by writing in terminal :
$ brew info python
or to check the version of pip write in terminal :
$ brew info pip
and make sure you have updated your both pip and python version (write in terminal $ brew upgrade pip/python)
and other way to install python is go to https://www.python.org/downloads/ and choose as your requirement, there is two version available 2.7.9 & 3.4.3 ,
after installing python write in terminal $ python -V to check its version :) Hope it will help :)
All I want to do is run a Python script that requires Python 2.7 & Requests on my Ubuntu 10.04 EC2 box.
I installed Python 2.7, no problem. "python" by itself still points to python 2.6, which is very annoying, b/c I'm not sure how ubuntu will freak if I change the symlink /usr/bin/python to point to 2.7.
I followed the (carefully buried) install instructions for pip (at http://www.pip-installer.org/en/latest/index.html, and which are WAY too hard to find if they aren't the ABSOLUTE FIRST command on the "install pip" page)
So, the real problem here is that pip install requests completes successfully, but only installs for python 2.6, not 2.7. The pip usage instructions say nothing about how to install a package for a specific version of python.
How do I do this?
I just want to run my python script that requires 2.7 + requests.
First install pip for your 2.7 distribution using easy_install (easy_install should definitely be included with your 2.7 distribution):
easy_install-2.7 -U pip
Then install what you need:
pip-2.7 install requests
Then you can run code with python2.7 instead of python.
Yeah it would be a bad idea to change the link pointing to which python version. Instead, can you change the shebang to say #!/usr/bin/env python2.7 instead of #!/usr/bin/env python ?
Though python2.7 /path/to/pip install requests might work; you should install pip for python2.7 separately instead.
If you don't use virtualenv then invoke pip as pip-2.7 (the command is available if you install pip for python2.7).
Follow installation instructions which is the first item in the table of contents. Substitute python with python2.7 in the instructions.
I am using ubuntu, linux kernel 2.6.38. I usually use python2, today, I decide to try Python3. I downloads python3 and make install it following the README. However,the python 3.2 interpreter can not recognize UP/SOWN/LEFT/RIGHT keys, these keys are available in my python 2.7 interpreter. What's wrong did I make?
Another question is can I choose the python version which iPython use if I have python2.7 and python3.2 at the same time.
Best Regards.
This happens if the GNU Readline Library is not installed. Install the development version of the Readline library and recompile. (Some Linux distros have different packages for the development version and the runtime version of a library. The development version is needed to compile packages which use the library.)
On Debian-derived distros like Ubuntu, the package is libreadline-dev.
sudo apt install libreadline-dev
On Redhat-derived distros like Fedora, the package is named readline-devel.
sudo dnf install readline-devel
You may be able to use the Editline library instead of Readline. It’s basically a different library that does the same thing.
This happens when compiling python without readline support.
Install the readline developement pakckages so that the readline.so module gets build when compiling.
If you want to use ipython on both python2 and python3, you'll have to install it separately for each interpreter.
One last hint: the ubuntu already has python3 in it's repository. you can install it using:
sudo apt-get install python3 ipython3
I'm a mac newbie and I tried to update my python version from 2.6 to 2.7. Unsuccessful, I changed my mind and uninstalled the python2.7 I had. I had a previous issue that if I typed something like:
python setup.py install
It would not install the package for python2.6, installing to the removed 2.7 version instead, to make it work I have to put
python2.6 setup.py install
And now when I try to install something with easy_install or pip (by the way, pip I have installed after 2.7 issue) I got the following huge message errors: here and here. I want to know how can I clean up my mess.
Since you were trying to install MySQLdb, how about you give ActivePython a try?
Install ActivePython 2.7 (it co-exists with Apple's System Python 2.6)
Open Terminal and type pypm install mysql-python (see PyPM Index) .. no compilation required
Make sure that /usr/local/bin/ is in front of your $PATH.
To uninstall ActivePython, you can do:
sudo /Library/Frameworks/Python.framework/Versions/2.7/Resources/Scripts/uninstall
Or, use sudo pythonselect 2.6 to switch the default Python in /usr/local/bin (if you have multiple versions of non-System Pythons installed)