installing packages over pythonbrew - python

I installed python 2.7 with python brew. How do I install packages to work with it? I installed MySQLdb with synaptic, but I am unable to import it in python 2.7.

Switch to 2.7:
pythonbrew switch 2.7
Curl and run get-pip to get the correct version of pip for 2.7:
curl -O https://raw.github.com/pypa/pip/master/contrib/get-pip.py
python get-pip.py
This will install the version of pip for 2.7. Check it by doing:
pip --version
Turn off pythonbrew:
pythonbrew off
Check the version of pip again, and it should be using the one for your default Python:
pip --version
If all is good, then switch back to 2.7 in pythonbrew and install mysql-python for 2.7:
pythonbrew switch 2.7
pip install mysql-python
Check to see that it is installed for 2.7:
pip freeze
Pip freeze will give you a listing of all installed libraries for the current active version of Python.

You should try to install pip, which is a recursive acronym: Pip Installs Packages. This thread talks about installing it on windows, on Ubuntu I did sudo apt get install pip.
Ok, your problem is that "mysqldb" is not a python package. You need to use MySQLdb as a backend, or simply install sqlite3 and import that into Python, which is a module that mimics SQL. If you end up using an actual full-on database, like MySQLdb or PostgreSQL, you'll probably need to install SQLAlchemy, which is a Python module to interface with those.

You need to install a version of pip for each Python version. Do you have easy install available? If so you can do
easy_install-2.7 pip
Is there a specific reason that you are installing Python via home brew though? You do know that Ubuntu has as a package.
sudo apt-get install python2.7
Will give you a version of Python that is already nicely set up.
I also believe that you should be trying to install the Python package called mysql-python.
pip install mysql-python
MySQLDB is not a Python package. It's the actual database.

Agree with #leta-rogers. However, I didn't have to install pip separately. Installing python using pythonbrew installed pip (for python 2.7) for me as well:
pythonbrew install 2.7
pythonbrew switch 2.7
pip install mysql-python

Related

Pip broken after deleting python3.7 folders

I think I broke my pip after desperately trying to uninstall Python3.7. (I am on a Mac)
I removed the python folder from the application, removed /Library/Frameworks/Python.framework and removed the folders from /usr/local/bin according to https://osxuninstaller.com/uninstall-guides/properly-uninstall-python-mac/. I then installed python3.6.
src$ pip3.6 --version pip 9.0.1 from
/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages
(python 3.6)
but pip itself does no longer work.
src$ which pip
/usr/local/bin/pip
src$ pip --version
-bash: /Library/Frameworks/Python.framework/Versions/3.7/bin/pip: No such file or directory $
It still references the python 3.7 folder. How can I unlink that reference? THe same is btw. true for the package virtualenv that I installed. I can install it with pip3.6 but calling virtualenv still references to the framework folder of 3.7
You need to install pip in that environment. i.e 3.7.
Reason is when you deleted the default install you deleted the dependencies/ libraries that came with it.
Easiest way is to install python afresh via homebrew if you have it.
brew install python
Alternatively you can follow the instructions here to download a file to install pip securely. Homebrew can become messy when managing python environments. I'd recommend looking at something like anaconda if you are going to using different python versions with their own dependencies etc.
curl https://bootstrap.pypa.io/get-pip.py -o get-pip.py
python get-pip.py
https://pip.pypa.io/en/stable/installing/#installing-with-get-pip-py
Other options for fresh install are described in answer here. Hope that helps.
How do I install pip on macOS or OS X?

Import Error - Tornado requires an updated SSL module on ubuntu 14.04

while installing juypter notebook on my ubuntu 14.04 I am getting this:
ImportError: Tornado requires an up-to-date SSL module. This means Python 2.7.9+ or 3.4+ (although some distributions have backported the necessary changes to older versions).
Pip is:
pip 10.0.1 from /usr/local/lib/python2.7/dist-packages/pip (python 2.7)
how to resolve this ?
Latest tornado library doesn't support your interpreter version. You have two options.
Either install old tornado (recommended):
pip install tornado==4.*
pip install jupyter
Or install new python. Ubuntu doesn't provide an official package for it, so you have to use community package:
sudo add-apt-repository ppa:jonathonf/python-2.7
sudo apt-get update
sudo apt-get install python2.7
pip install jupyter
python -m pip install --upgrade pip setuptools wheel
ref: https://packaging.python.org/tutorials/installing-packages/

How to install pip with a specific python version

I want to install pip for python 2.7, but I am also having python 3.x but both locations are different. when ever I install or update the pip It is installing in the python 3.x location.
How to install pip for python 2.7?
I recently found the following solution, when you are maintaining python2.x and python 3.x in host system. You can find the pip under Scripts folder.
Try pip --version it gives pip version and python version as well
If you want to install package using pip use the following commands.
python -m pip install package_name
python2.x -m pip install package_name
Which reads the specified python pip module to install the package

Install python module for non-default version on linux

I have different python versions installed on my ubuntu machine. The default version is 2.7.
So when I install any new python module, for example using:
#apt-get install python-nfqueue
it will be istalled just for the default version (2.7)
How can I install the new modules for the other versions?
Is there a way to do it using apt-get install?
Thank you!
You should install Python libraries with the Python package installer, pip.
Create a virtualenv with the Python version you want to use, activate it, and do pip install NetfilterQueue. You'll still need to install the system dependencies (eg libnetfilter-queue-dev in this case) with apt-get.
You can install pip to work with different versions of python. Here is a link to the pip read the docs page(http://pip.readthedocs.org/en/latest/installing.html).
to install pip to the default version of python on your machine:
python get-pip.py
to install for non standard versions call python with the version you wish to install for:
python33 get-pip.py
you can then run pip for python version 3.3 by calling
pip33 install pythonmodule

Installing pip with correct python version

I am on shared hosting and I need to install pip with the correct python version, 2.7. To install pip, I did:
$ easy_install pip
However, after it was installed I get the following:
[dave#web1 lib]$ pip --version
pip 1.0.2 from /home/premiere/dave/financials/lib/pip-1.0.2-py2.7.egg (python 2.4)
How would I re-install pip to work on the python2.7 version, which is also installed on the machine?
[premiered#web1 ~]$ python --version
Python 2.6.6
Which is strange, since it is installing to python2.4.
You may want to create a virtualenv using -p /path/to/python-2.7.binary param, and then activate it. Then all stuff you installed using pip would be correctly into your virtualenv.
If multiple versions of python are installed on the system, then you should invoke the version you want when installing. i.e.
$ python27 easy_install pip
This creates a pip file in your path that contains the specified version of python in the hashBang line.

Categories

Resources