Installing Python with MySQL connector on Red Hat - python

I'm having trouble making MySQL connector work with Python.
I started with a fresh new installation of Red Hat 6.4.
The system already had Python 2.6.6 installed by default, I need however version 3.4
I downloaded, compiled and installed Python 3.4 from here (https://www.python.org/ftp/python/3.4.4/Python-3.4.4.tgz)
I downloaded and installed the MySQL yum repository from here (http://dev.mysql.com/get/mysql57-community-release-el6-8.noarch.rpm)
Installed mysql-community-server version 5.7 with yum
Finally I installed mysql-connector-python with yum (version 2.1.3)
Now it looks like the module works in Python 2.6.6 but it can't find the module with Python 3.4.
I'm a bit stuck with how to get round this.

Since you got the mysql-connector via yum, it's installed for the system python. Your custom python 3 environment doesn't know about it.
So it's probably best to do the following:
Get pip and install it for your python 3. Make sure that python points to your custom installation when executing python get_pip.py
Get the source distribution of the mysql-connector: https://dev.mysql.com/get/Downloads/Connector-Python/mysql-connector-python-2.1.3.tar.gz
Use your just installed pip to install the mysql-connector from source into your python environment: pip install path/to/mysql-connector-python-2.1.3.tar.gz
Alternatively you might look into using virtualenv.

Related

How to Set Default Version of Python to 3.x vs 2.7 on Mac OSX?

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.

Install Python 3.5 on Mac for IntelliJ IDEA / PyCharm

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.

Install python2.7 on Ubuntu 14.04

How can I install python2.7 on Ubuntu 14.04 and make the system's default python the python I installed?
How can I install packages like numpy, scipy and so on in the python I installed? I don't know how to set these settings.
As Selcuk and warmoverflow said, both versions of python , python 2.x and 3.x comes already installed on ubuntu. However if you want to upgrade your python version, say python 2.7.6 to python 2.7.11 or so, you can upgrade it by downloading the latest version and building it from source.
Here is a good tutorial for that : Tutorial 1 Tutorial 2
You can also search on internet for the same.

Django is installing to the wrong python version

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

How can I uninstall python 2.6.5 and install the newest version(2.7.3) in ubuntu 10.04

I want to uninstall python 2.6.5, and install python 2.7.3
but there is so many other software relay on it.
so how can I up upgrade python in ubuntu10.04?
I used this link to do the same(i.e the installation part), after doing this the default python version will change to 2.7.3.
Another useful link How do I install python 2.7.2 on 10.04?.
Why do you want to uninstall the old one? You can install python 2.7 and just create a virtualenv that points to it: Use different Python version with virtualenv
Aside from that, it's rather risky to upgrade it, if you don't want to upgrade the whole system.

Categories