I am not sure if this is a bug, or if I am doing something wrong.
The situation is the following,
pip list -o
yields a list of outdated python packages along with what is suppose to be the current installed version.
The issue is that I am pretty sure that it is giving me the wrong information on at least some packages as I can verify, as in the example below, that the version of ipython that pip thinks is installed (2.0.0) is not the one that I get when I run ipython from the command prompt (version==2.1.0).
kolmogorov:~# pip list -o | head -15
Warning: cannot find svn location for PEAK-Rules==0.5a1.dev-r2707
Warning: cannot find svn location for prioritized-methods==0.2.2dev-20110830
scipy (Current: 0.13.2 Latest: 0.14.0)
plotly (Current: 1.0.30 Latest: 1.0.32)
SOAPpy (Current: 0.12.21 Latest: 0.12.22)
openpyxl (Current: 1.8.6 Latest: 2.0.3)
networkx (Current: 1.8.1 Latest: 1.9)
setuptools (Current: 3.4.1 Latest: 5.1)
brewer2mpl (Current: 1.3.2 Latest: 1.4)
repoze.who (Current: 1.0.19 Latest: 2.2)
pandas (Current: 0.13.1 Latest: 0.14.0)
pygeocoder (Current: 1.2.2 Latest: 1.2.5)
ipython (Current: 2.0.0 Latest: 2.1.0)
tornado (Current: 3.2 Latest: 3.2.2)
Could not find any downloads that satisfy the requirement vboxapi
Traceback (most recent call last):
File "/usr/bin/pip", line 9, in <module>
load_entry_point('pip==1.5.6', 'console_scripts', 'pip')()
File "/usr/lib/python2.7/dist-packages/pip/__init__.py", line 235, in main
return command.main(cmd_args)
File "/usr/lib/python2.7/dist-packages/pip/basecommand.py", line 156, in main
logger.fatal('Exception:\n%s' % format_exc())
File "/usr/lib/python2.7/dist-packages/pip/log.py", line 111, in fatal
self.log(self.FATAL, msg, *args, **kw)
File "/usr/lib/python2.7/dist-packages/pip/log.py", line 164, in log
consumer.flush()
IOError: [Errno 32] Broken pipe
kolmogorov:~# ipython
Python 2.7.7 (default, Jun 3 2014, 16:16:56)
Type "copyright", "credits" or "license" for more information.
IPython 2.1.0 -- An enhanced Interactive Python.
? -> Introduction and overview of IPython's features.
%quickref -> Quick reference.
help -> Python's own help system.
object? -> Details about 'object', use 'object??' for extra details.
My question is: Is there a way to have pip understand the correct version of the installed python packages?
You can run the following commands to see where the package is from:
which ipython
and:
pip show ipython
You may have two installations: one that was installed with pip install ipython and an installation via a separate tool (package manager on Linux or Ports/brew on Mac).
So the way to do this properly is a little bit more involved than what I anticipated, but I have to submit it as the proper answer as it actually resolves the issue.
Suppose the package version that is misunderstood by pip is pandas. So that the behavior you observe is that:
pip list --outdated
says that the version of pandas you have installed is 0.14.0; but when you inquire about the version of pandas in say ipython:
In [1]: import pandas
In [2]: pandas.__version__
Out[2]: '0.14.1'
In order to resolve this:
run pip show pandas; it should tell you about the location of the distribution, in my case /usr/local/lib/python2.7/dist-packages
redirect to that location cd /usr/local/lib/python2.7/dist-packages
run ls -lstrh pandas-0.14.*; you should see files associated with both your 0.14.1 version and the 0.14.0 one you want to get rid of
run rm -rf pandas-0.14.0*.egg-info pandas-0.14.0*.pth
That should be it!
pip show pandas
should now agree with what pandas.__version__
Related
I had update Robot Framework into the newer version
Here are pip list that I had already download
Package Version
------------------------------- -----------
Appium-Python-Client 0.49
certifi 2020.6.20
chardet 3.0.4
decorator 4.4.2
django-robots 4.0
docutils 0.16
idna 2.10
kitchen 1.2.6
numpy 1.19.1
Pillow 7.2.0
pip 19.0.3
Pygments 2.6.1
PyPubSub 3.3.0
pywin32 228
requests 2.24.0
robot 20071211
robotframework 3.2.1
robotframework-appiumlibrary 1.5.0.4
robotframework-databaselibrary 1.2.4
robotframework-pythonlibcore 2.1.0
robotframework-requests 0.7.1
robotframework-ride 1.7.3.1
robotframework-selenium2library 3.0.0
robotframework-seleniumlibrary 3.3.1
robotframeworklexer 1.1
selenium 3.141.0
setuptools 40.8.0
six 1.15.0
urllib3 1.25.10
wxPython 4.0.7.post2
You are using pip version 19.0.3, however version 20.2.2 is available.
You should consider upgrading via the 'python -m pip install --upgrade pip' command.
Python that I chosen is 3.7.4
However, I need to executes the script, which it should be execute normally. However, I found that it caught error
Traceback (most recent call last):
File "d:\lib\runpy.py", line 193, in _run_module_as_main
"__main__", mod_spec)
File "d:\lib\runpy.py", line 85, in _run_code
exec(code, run_globals)
File "D:\Scripts\robot.exe\__main__.py", line 5, in <module>
ModuleNotFoundError: No module named 'robot'
that I don't understand that cause of error.
I have already got robot files as well
Have you found a solution yet? I doubt if your command to execute robot is correct.
robot <Path to robot file> will execute it.
for example robot Tests/my_robot_test.robot and if you have tags assigned, you can run specific tag test cases with robot -i <tag_id> Tests/my_robot_test.robot
While trying to install the tool PrimerProspector from the development version (SVN trunk, as instructed here: http://pprospector.sourceforge.net/install/install.html) I tried creating a conda environment to resolve the dependencies in an elegant way (I am running an Ubuntu server 16.04.3 LTS machine with conda 4.4.8). The PyCogent and Numpy can easily be installed in the required version using pip install when the environment (with python 2.6) is activated. I have conda forge in my channels. However, when running pip install matplotlib==0.98.5.3 I run into the issue that there is no such version available (Could not find a version that satisfies the requirement matplotlib==0.98.5.3 (from versions: 0.86, 0.86.1, 0.86.2, 0.91.0, 0.91.1, 1.0.1, 1.1.0, 1.1.1, 1.2.0, 1.2.1, 1.3.0, 1.3.1, 1.4.0, 1.4.1rc1, 1.4.1, 1.4.2, 1.4.3, 1.5.0, 1.5.1, 1.5.2, 1.5.3, 2.0.0b1, 2.0.0b2, 2.0.0b3, 2.0.0b4, 2.0.0rc1, 2.0.0rc2, 2.0.0, 2.0.1, 2.0.2, 2.1.0rc1, 2.1.0, 2.1.1, 2.1.2)). Additionally I get an InsecurePlatformWarning which is apparently common with an older Python distribution. Nevertheless, as the source was available I tried using pip to install from the tarball. This gives me the rather uninformative KeyError: 'linux3':
Complete output from command python setup.py egg_info:
============================================================================
BUILDING MATPLOTLIB
matplotlib: 0.98.5.3
python: 2.6.9 | packaged by conda-forge | (unknown, Apr 29
2017, 15:44:38) [GCC 4.8.2 20140120 (Red Hat
4.8.2-15)]
platform: linux3
REQUIRED DEPENDENCIES
Traceback (most recent call last):
File "<string>", line 20, in <module>
File "/tmp/pip-7ZwjL5-build/setup.py", line 99, in <module>
if not check_for_numpy():
File "setupext.py", line 497, in check_for_numpy
add_base_flags(module)
File "setupext.py", line 319, in add_base_flags
[os.path.join(p, 'include') for p in basedir[sys.platform] ])
KeyError: 'linux3'
----------------------------------------
Directly running setup.py after untarring also renders the same error. Does anyone know how to resolve this? Is there anything I can do to find out?
The mathplotlib version you're trying to use has been released years before the release of Linux 3.0. That's why it has no support for sys.platform='linux3'. And the Python version you're using is older than 2.7.2, which dropped setting the linux3 value.
You can try to just edit the setupext.py file in the tarball, and in the dict basedir add config for linux3, which would be the same as for linux and linux2.
I'm wondering about the following importError which I can't get ride off. I have a local virtualenv (venv) in which I've installed multiple modules:
(venv) stam#stam:~$ pip list --local
cryptography (1.5.2)
cvxopt (1.1.9)
cycler (0.10.0)
Cython (0.25.1)
matplotlib (1.5.3)
more-itertools (2.2)
ndg-httpsclient (0.4.2)
numpy (1.11.2)
pandas (0.19.0)
paramiko (1.15.2)
Pillow (2.8.1)
pip (8.1.2)
psycopg2 (2.6)
python-apt (0.9.3.12)
python-dateutil (2.5.3)
python-debian (0.1.27)
scipy (0.18.1)
setuptools (28.6.1)
simplejson (3.8.2)
urllib3 (1.9.1)
wheel (0.24.0)
You are using pip version 8.1.2, however version 9.0.1 is available.
You should consider upgrading via the 'pip install --upgrade pip' command.
(venv) stam#stam:~$
now starting a python interpreter and trying to import cvxopt (note it is in the list above) gives me a importError. Why is this? I'm using the right python version, I work on the venv so everything should work out of the box.
(venv) stam#stam:~$ python
Python 2.7.9 (default, Aug 13 2016, 16:41:35)
[GCC 4.9.2] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> import cvxopt
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
ImportError: No module named cvxopt
>>>
I'm a bit lost and don't know how exactly I can resolve this issue. It seems the right python version is started, at least the one I've attached to the virtualenv.
Additional outps asked for in the comments
(venv) stam#stam:~$ which python
/usr/bin/python
(venv) stam#stam:~$ which pip
/usr/local/bin/pip
Based on the output from which it seems clear that your python and pip belong to two different instances. So all libraries you install will be installed for some other python instance.
The acute fix is to force pip to run through your specified interpreter:
python -m pip list --local
python -m pip install cvxopt
I'm trying to install ntlk for a Django project. I followed the intstructions on NTLK's website, and I they worked because when I try to install again with pip, I get:
➜ Word_Maker git:(master) sudo pip install -U numpy
Requirement already up-to-date: numpy in /Library/Frameworks/Python.framework/Versions/3.3/lib/python3.3/site-packages
Cleaning up...
➜ Word_Maker git:(master) sudo pip install -U pyyaml nltk
Requirement already up-to-date: pyyaml in /Library/Frameworks/Python.framework/Versions/3.3/lib/python3.3/site-packages
Requirement already up-to-date: nltk in /Library/Frameworks/Python.framework/Versions/3.3/lib/python3.3/site-packages
Cleaning up...
However, when I do import ntlk from python3, I get:
Python 3.3.3 (v3.3.3:c3896275c0f6, Nov 16 2013, 23:39:35)
[GCC 4.2.1 (Apple Inc. build 5666) (dot 3)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> import nltk
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/Library/Frameworks/Python.framework/Versions/3.3/lib/python3.3/site-packages/nltk/__init__.py", line 37
except IOError, ex:
^
SyntaxError: invalid syntax
^
SyntaxError: invalid syntax
import numpy works, however. Any help would be appreciated!
It seems you made a spelling mistake:
Requirement already up-to-date: nltk in /Library/Frameworks/Python.framework/Versions/3.3/lib/python3.3/site-packages
And you're trying to import ntlk. Try using import nltk.
As for the import error, the following from their website:
NLTK requires Python versions 2.6-2.7. (A version supporting Python 3 is available at http://nltk.org/nltk3-alpha/).
So NLTK does not (yet) support python 3.3 fully.
First remove NLTK using pip: sudo pip uninstall nltk
Then download the source. And install using sudo python setup.py install
And try again. Be aware this is an alpha, so expect some methods to randomly throw errors or generate unexpected output.
If you still have this error after fixing the spelling, the issue is that PyPI is installing an older NLTK package (2.x). Check this by looking at the first message in the terminal immediately after your run sudo pip install nltk.
To install the latest version of NLTK (3.x) that is compatible with Python 3, first sudo pip uninstall nltk.
Then use:
sudo pip install nltk==3.0.0b2
The latest version number is found here: https://pypi.python.org/pypi/nltk
Sometimes the versions of dependent packages may cause issues. The main issue is old, but I found a slightly different problem when using the parser - which internally was going into scipy. Solved using:
pip3 uninstall nltk scipy matplotlib
pip3 install -U nltk scipy matplotlib
Edit: Before you start deleting/modifying installs, please glance over StvnW's answer/summary to make sure you are applying the solution that is appropriate for you.
I've installed python 2.7.5 and pip [edit: mac OSX Mountain Lion.] I've run "pip install praw" in terminal. All good. When I run python and run "import praw" I get:
...$ python
Python 2.7.5 (v2.7.5:ab05e7dd2788, May 13 2013, 13:18:45)
[GCC 4.2.1 (Apple Inc. build 5666) (dot 3)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> import praw
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
ImportError: No module named praw
...same ImportError from a script.
when I install praw I get this:
$ pip install praw
Downloading/unpacking praw
Downloading praw-2.1.10.tar.gz (83kB): 83kB downloaded
Running setup.py egg_info for package praw
Requirement already satisfied (use --upgrade to upgrade): requests>=1.2.0 in
/usr/local/lib/python2.7/site-packages (from praw)
Requirement already satisfied (use --upgrade to upgrade): six in
/usr/local/lib/python2.7/site-packages (from praw)
Requirement already satisfied (use --upgrade to upgrade): update-checker>=0.6 in
/usr/local/lib/python2.7/site-packages (from praw)
Requirement already satisfied (use --upgrade to upgrade): setuptools in
/usr/local/lib/python2.7/site-packages/setuptools-1.1.6-py2.7.egg (from update-
checker>=0.6->praw)
Installing collected packages: praw
Running setup.py install for praw
Installing praw-multiprocess script to /usr/local/bin
Successfully installed praw
Cleaning up...
In python if I run help('modules') it isn't there.
Relatively new to python and I haven't been able to sort this out with google search. Any hints would be much appreciated.
Edit:
SitRep:
I've uninstalled 2.7.2, uninstalled praw, and uninstalled (homebrew) pip. I ran python 2.7.5 and it couldn't find the module (as you would suspect.) I then reinstalled pip with easy_install and now 2.7.5 is finding praw but giving this error:
$ python
Python 2.7.5 (v2.7.5:ab05e7dd2788, May 13 2013, 13:18:45)
[GCC 4.2.1 (Apple Inc. build 5666) (dot 3)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> import praw
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/Library/Python/2.7/site-packages/praw/__init__.py", line 43, in <module>
from update_checker import update_check
File "/Library/Python/2.7/site-packages/update_checker.py", line 11, in <module>
from pkg_resources import parse_version as V
ImportError: No module named pkg_resources
>>>
Thanks for the help so far, the spurious install was the root of problem 1.
The solution to the final problem can be found here:
No module named pkg_resources
I wish there were some way to summarize this for future readers, but I've done so many things that I no longer recall what addressed what. I basically uninstalled everything (python 2.7.2, 2.7.5, praw, pip,) reinstalled 2.7.5 from http://python.org/download/, reinstalled pip with easy_install (and sudo command) instead of homebrew, reinstalled praw with sudo command, and followed the directions for the subsequent module error in the link above. Hope that helps. :)
The OS X system versions of Python live in /System/Library/Frameworks/Python.Framework/<verson>, each of which links to /Library/Python/<version>/site-packages. Seems like you have installed another version of python and/or pip to /usr/local, but when you invoke python you are still getting the system version.
Try this:
$ /usr/local/bin/python
>>> import praw
I'd also recommend looking into tools like pyenv and virtualenv if you are going to do any amount of work with Python. Pyenv lets you easily manage and switch between multiple versions (including micro versions x.x.3, x.x.5, etc). Virtualenv lets you create isolated Python environments where you can pin down versions of site-packages specific to a particular project.
Edit (summarizing):
sudo easy_install pip will install pip under /System/Library/Python/<version>. Calling that pip will install packages to /Library/Python/<version>/site-packages
brew install python will install a second version of python — including pip — under /usr/local/. That pip will put packages in /usr/local/lib/python<version>/site-packages/`.
One version may not see packages installed to the other.
which python and which pip are helpful for troubleshooting.
Dean's final solution above results in user packages being installed to the system site-packages.
Despite Dean's choice to update the system Python, many would advocate instead using brew, pyenv, and virtualenv to isolate oneself from the system Python.
It's strange. I am suspecting you have another version of python2.7 on your mac os
If you are using a mac. Check the version of python on your shell's path using which python. Then make sure that the shebang line in the script you are trying to run uses the same version of python.
In my terminal I typed
which python and got the output /usr/local/bin/python
I went to the script I was trying to run and added the following to the first line
#!/usr/local/bin/python
Then I went back to my terminal. Checked that I was in the same directory as the script I wanted to run and typed
./my_script.py
If you don't see any output at this point make sure that you have execution permission enabled for your script by typing chmod +x my_script.py in ther terminal. Then try running the script again using ./my_script.py