Error: "Traceback (most recent call last):" - python

I'm trying to install pip to my pycharm, I'm using Mac OS X version 10.11.1
I tried: pip install --upgrade pip
Then I get:
Traceback (most recent call last):
File "/usr/local/bin/pip", line 5, in <module>
from pkg_resources import load_entry_point
File "/System/Library/Frameworks/Python.framework/Versions/2.7/Extras/lib/python/pkg_resources.py", line 2793, in <module>
working_set.require(__requires__)
File "/System/Library/Frameworks/Python.framework/Versions/2.7/Extras/lib/python/pkg_resources.py", line 673, in require
needed = self.resolve(parse_requirements(requirements))
File "/System/Library/Frameworks/Python.framework/Versions/2.7/Extras/lib/python/pkg_resources.py", line 576, in resolve
raise DistributionNotFound(req)
pkg_resources.DistributionNotFound: pip==7.1.0
I'm stuck a few days.

Don't modify your system python. Instead, install a new version of python with pyenv. And then create a new env for each project use virtualenv or venv if you are using py3k.

Related

Cfgrib is not installed correctly on WSL2 through pip

I'm trying to install cfgrib to my WSL2 Ubuntu however when I type python3 -m cfgrib selfcheck it gives the following error as follows.
Traceback (most recent call last):
File "/home/berke/.local/lib/python3.8/site-packages/cfgrib/messages.py", line 42, in <module>
import pyeccodes.compat as eccodes
ModuleNotFoundError: No module named 'pyeccodes'
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "/usr/lib/python3.8/runpy.py", line 184, in _run_module_as_main
mod_name, mod_spec, code = _get_module_details(mod_name, _Error)
File "/usr/lib/python3.8/runpy.py", line 143, in _get_module_details
return _get_module_details(pkg_main_name, error)
File "/usr/lib/python3.8/runpy.py", line 110, in _get_module_details
__import__(pkg_name)
File "/home/berke/.local/lib/python3.8/site-packages/cfgrib/__init__.py", line 19, in <module>
from .cfmessage import CfMessage
File "/home/berke/.local/lib/python3.8/site-packages/cfgrib/cfmessage.py", line 29, in <module>
from . import messages
File "/home/berke/.local/lib/python3.8/site-packages/cfgrib/messages.py", line 44, in <module>
raise exc
File "/home/berke/.local/lib/python3.8/site-packages/cfgrib/messages.py", line 37, in <module>
from . import bindings as eccodes
File "/home/berke/.local/lib/python3.8/site-packages/cfgrib/bindings.py", line 57, in <module>
raise RuntimeError(f"ecCodes library not found using {LIBNAMES}")
RuntimeError: ecCodes library not found using ['eccodes', 'libeccodes.so', 'libeccodes']
My python version is Python 3.8.2. Is it possible to install cfgrib through pip?
The latest release of cfgrib version 0.9.8.5 at PyPI doesn't declare eccodes or pyeccodes as a dependency, not even as extra. You can install one of them separately:
pip install eccodes
or
pip install pyeccodes
(I don't know what is the difference; cfgrib can use both).
The bug is fixed in the repository but not yet released to PyPI so you can try to install the latest version using git:
pip install --upgrade "git+https://github.com/ecmwf/cfgrib.git#egg=cfgrib"

zipimport.ZipImportError: can't decompress data; zlib not available in Linux

I have two python versions, two different places 2.6 and 2.7, as shown below
#python --version
Python 2.6.6
#/usr/local/python27/bin/python2.7 --version
Python 2.7.15
I need to install paramiko module, which doesn't exists, So trying to install through pip, pip its self prompting below error
# pip --version
Traceback (most recent call last):
File "/usr/bin/pip", line 5, in <module>
from pkg_resources import load_entry_point
File "/usr/lib/python2.6/site-packages/pkg_resources/__init__.py", line 959, in <module>
class Environment:
File "/usr/lib/python2.6/site-packages/pkg_resources/__init__.py", line 963, in Environment
self, search_path=None, platform=get_supported_platform(),
File "/usr/lib/python2.6/site-packages/pkg_resources/__init__.py", line 190, in get_supported_platform
plat = get_build_platform()
File "/usr/lib/python2.6/site-packages/pkg_resources/__init__.py", line 393, in get_build_platform
from sysconfig import get_platform
ImportError: No module named sysconfig
So I install get-pip.py and trying to configure as below , though I have installed zlib
# ./python2.7 get-pip.py
Traceback (most recent call last):
File "get-pip.py", line 21401, in <module>
main()
File "get-pip.py", line 197, in main
bootstrap(tmpdir=tmpdir)
File "get-pip.py", line 82, in bootstrap
import pip._internal
zipimport.ZipImportError: can't decompress data; zlib not available
Since my python2.7 custom installation, again I tried on configure with LDFLAGS="-Wl,--rpath=/usr/include/" where the zlib library located at /usr/include/ though still I am getting the "zipimport.ZipImportError:" error, your help much appreciated.
./configure --enable-shared \
--prefix=/usr/local/python27 \
LDFLAGS="-Wl,--rpath=/usr/include/"

Centos 6.5 error installing wal-e

On a fresh CentOS 6.5 install (Python 2.6.6), after doing pip install wal-e successfully, running wal-e gives the following error:
# wal-e
Traceback (most recent call last):
File "/usr/bin/wal-e", line 5, in <module>
from pkg_resources import load_entry_point
File "/usr/lib/python2.6/site-packages/pkg_resources.py", line 2655, in <module>
working_set.require(__requires__)
File "/usr/lib/python2.6/site-packages/pkg_resources.py", line 648, in require
needed = self.resolve(parse_requirements(requirements))
File "/usr/lib/python2.6/site-packages/pkg_resources.py", line 546, in resolve
raise DistributionNotFound(req)
pkg_resources.DistributionNotFound: argparse>=0.8
If i do pip list argparse I get a bunch of stuff, including argparse 1.3.0
You're missing the argparse package. wal-e is looking for version 0.8 or higher.
pip install argparse
Also see this:
pip broke. how to fix DistributionNotFound error?

import error when trying to use pip command in ubuntu terminal

I just installed pip with ubuntu onto my laptop. Whenever I try to use pip in the terminal, I keep getting this error:
lopuj#lopuj-Dell-System-XPS-L502X:~$ pip
Traceback (most recent call last):
File "/usr/local/bin/pip", line 9, in <module>
load_entry_point('pip==1.4.1', 'console_scripts', 'pip')()
File "/usr/local/lib/python3.4/dist-packages/setuptools-1.1.5-py3.4.egg/pkg_resources.py", line 357, in load_entry_point
def get_entry_info(dist, group, name):
File "/usr/local/lib/python3.4/dist-packages/setuptools-1.1.5-py3.4.egg/pkg_resources.py", line 2394, in load_entry_point
break
File "/usr/local/lib/python3.4/dist-packages/setuptools-1.1.5-py3.4.egg/pkg_resources.py", line 2108, in load
name = some.module:some.attr [extra1,extra2]
ImportError: No module named 'pip'
lopuj#lopuj-Dell-System-XPS-L502X:~$ ^C
lopuj#lopuj-Dell-System-XPS-L502X:~$
How can I stop this from happening so i can just type in commands like 'pip install Django==1.7.1'?
Your referencing
usr/local
but pip is installed at
usr/lib
Check your installation. I would reinstall using esay_install and then open/close terminal.

Python PyQt4 ImportError when using Homebrew and Virtualenv in OSX Mavericks

PyQt4 is installed on a OSX system using homebrew and using python 2.7.5. Virtualenvwrapper is used to setup an environment for the current project.
Running a python script that imports the PyQt4 module gives the following error:
Traceback (most recent call last):
File "test.py", line 9, in <module>
from PyQt4.QtGui import *
ImportError: No module named PyQt4.QtGui
brew test pyqt popups a PyQt window and the test appears to pass.
$ brew install PyQt
Warning: pyqt-4.10.4 already installed
Question: Why does the ImportError still occurs?
Attempt 1
Copied the pyqt directory from brew's install directory to virtualenv's lib/python-2.7/site-packages directory. Still getting the same error
File "test.py", line 9, in <module>
from PyQt4.QtGui import *
ImportError: No module named PyQt4.QtGui
Attempt 2
$ virtualenv test
Traceback (most recent call last):
File "/usr/local/bin/virtualenv", line 5, in <module>
from pkg_resources import load_entry_point
File "/System/Library/Frameworks/Python.framework/Versions/2.7/Extras/lib/python/pkg_resources.py", line 2603, in <module>
working_set.require(__requires__)
File "/System/Library/Frameworks/Python.framework/Versions/2.7/Extras/lib/python/pkg_resources.py", line 666, in require
needed = self.resolve(parse_requirements(requirements))
File "/System/Library/Frameworks/Python.framework/Versions/2.7/Extras/lib/python/pkg_resources.py", line 565, in resolve
raise DistributionNotFound(req) # XXX put more info here
pkg_resources.DistributionNotFound: virtualenv==1.10.1
To fix this error, we do:
$ easy_install --upgrade pip
$ virtualenv --system-site-packages test
Lets install a required package:
$ pip install pyserial
And we get the same error when we run the script that imports pyqt:
$ python test.py
File "test.py", line 9, in <module>
from PyQt4.QtGui import *
ImportError: No module named PyQt4.QtGui
Furthermore, virtualenv now appears broken in this virtualenv, but works in other virtualenvs:
$ virtualenv
Traceback (most recent call last):
File "/usr/local/bin/virtualenv", line 5, in <module>
from pkg_resources import load_entry_point
File "/System/Library/Frameworks/Python.framework/Versions/2.7/Extras/lib/python/pkg_resources.py", line 2603, in <module>
working_set.require(__requires__)
File "/System/Library/Frameworks/Python.framework/Versions/2.7/Extras/lib/python/pkg_resources.py", line 666, in require
needed = self.resolve(parse_requirements(requirements))
File "/System/Library/Frameworks/Python.framework/Versions/2.7/Extras/lib/python/pkg_resources.py", line 565, in resolve
raise DistributionNotFound(req) # XXX put more info here
pkg_resources.DistributionNotFound: virtualenv==1.10.1

Categories

Resources