Question or problem about Python programming:
On Ubuntu 10.04 by default Python 2.6 is installed, then I have installed Python 2.7. How can I use pip install to install packages for Python 2.7.
pip install beautifulsoup4
by default installs BeautifulSoup for Python 2.6
When I do:
in Python 2.6 it works, but in Python 2.7 it says:
No module named bs4
How to solve the problem:
Use a version of
pip installed against the Python instance you want to install new packages to.
In many distributions, there may be separate
python2.7-pip packages, invoked with binary names such as
pip-2.7. If pip is not packaged in your distribution for the desired target, you might look for a setuptools or easyinstall package, or use virtualenv (which will always include pip in a generated environment).
pip’s website includes installation instructions, if you can’t find anything within your distribution.
pip itself is written in python, you can just call it with the python version you want to install the package for:
python2.7 -m pip install foo
You can execute pip module for a specific python version using the corresponding python:
python2.6 -m pip install beautifulsoup4
python2.7 -m pip install beautifulsoup4
You can use this syntax
python_version -m pip install your_package
For example. If you’re running python3.5, you named it as “python3”, and want to install numpy package
python3 -m pip install numpy
In Windows, you can execute the pip module by mentioning the python version ( You need to ensure that the launcher is on your path )
py -2 -m pip install pyfora