I was trying to use celery, but ran into some compilation errors. As such, I tried to uninstall/reinstall Numpy and Skimage in an attempt to fix it.
I did not fix it, instead, I made it worse.
When I now use pip to install, uninstall or --upgrade it returns the following error.
rootadmin#annotatie01:/data_nfs/opensurfaces/venv/lib/python2.7/site-packages/numpy$ sudo -H python -m pip install pandas
Traceback (most recent call last):
File "/usr/lib/python2.7/runpy.py", line 151, in _run_module_as_main
mod_name, loader, code, fname = _get_module_details(mod_name)
File "/usr/lib/python2.7/runpy.py", line 109, in _get_module_details
return _get_module_details(pkg_main_name)
File "/usr/lib/python2.7/runpy.py", line 101, in _get_module_details
loader = get_loader(mod_name)
File "/usr/lib/python2.7/pkgutil.py", line 464, in get_loader
return find_loader(fullname)
File "/usr/lib/python2.7/pkgutil.py", line 474, in find_loader
for importer in iter_importers(fullname):
File "/usr/lib/python2.7/pkgutil.py", line 430, in iter_importers
__import__(pkg)
File "/usr/local/lib/python2.7/dist-packages/pip/__init__.py", line 21, in <module>
from pip._vendor.requests.packages.urllib3.exceptions import DependencyWarning
File "/usr/local/lib/python2.7/dist-packages/pip/_vendor/requests/__init__.py", line 62, in <module>
from .packages.urllib3.exceptions import DependencyWarning
File "/usr/local/lib/python2.7/dist-packages/pip/_vendor/requests/packages/__init__.py", line 29, in <module>
import urllib3
File "/usr/lib/python2.7/dist-packages/urllib3/__init__.py", line 16, in <module>
from .connectionpool import (
File "/usr/lib/python2.7/dist-packages/urllib3/connectionpool.py", line 17, in <module>
from httplib import HTTPConnection, HTTPException
File "/usr/lib/python2.7/httplib.py", line 80, in <module>
import mimetools
File "/usr/lib/python2.7/mimetools.py", line 6, in <module>
import tempfile
File "/usr/lib/python2.7/tempfile.py", line 35, in <module>
from random import Random as _Random
File "random/__init__.py", line 102, in <module>
ranf = random = sample = random_sample
NameError: name 'random_sample' is not defined
The same error is returned if i run python -m pip.__main__. I'm using a remote server running ubuntu 14.04
For some reason your current working directory is
/data_nfs/opensurfaces/venv/lib/python2.7/site-packages/numpy
which is inside the numpy package, so import random results in importing not the standard library random module, but the numpy.random package. Just cd out of that directory (in general don't run Python from inside packages under site-packages).
Even if you didn't know there were a numpy.random module you can glean this from the traceback:
File "/usr/lib/python2.7/tempfile.py", line 35, in <module>
from random import Random as _Random
File "random/__init__.py", line 102, in <module>
ranf = random = sample = random_sample
You can see that while tempfile was imported from an absolute path /usr/lib/python2.7/ (where the standard library is), random was imported from a relative path, that is, relative to your current directory.
Related
in my ubuntu 16.04 system, pyplot imshow() used to work fine both in system python and in a virtual environment (for tensorflow). If file aa.py contains lines below
import matplotlib.pyplot as p
p.plot(range(20),range(20))
p.show()
when I run python aa.py it runs ok. (I see a graph). but when I activate a virtual environment and run python aa.py in it, I see errors below :
Traceback (most recent call last):
File "aa.py", line 1, in <module>
import matplotlib.pyplot as p
File "/home/ckim/venv2/lib/python2.7/site-packages/matplotlib/pyplot.py", line 115, in <module>
_backend_mod, new_figure_manager, draw_if_interactive, _show = pylab_setup()
File "/home/ckim/venv2/lib/python2.7/site-packages/matplotlib/backends/__init__.py", line 62, in pylab_setup
[backend_name], 0)
File "/home/ckim/venv2/lib/python2.7/site-packages/matplotlib/backends/backend_tkagg.py", line 4, in <module>
from . import tkagg # Paint image to Tk photo blitter extension.
File "/home/ckim/venv2/lib/python2.7/site-packages/matplotlib/backends/tkagg.py", line 5, in <module>
from six.moves import tkinter as Tk
File "/home/ckim/venv2/lib/python2.7/site-packages/six.py", line 203, in load_module
mod = mod._resolve()
File "/home/ckim/venv2/lib/python2.7/site-packages/six.py", line 115, in _resolve
return _import_module(self.mod)
File "/home/ckim/venv2/lib/python2.7/site-packages/six.py", line 82, in _import_module
__import__(name)
File "/usr/lib/python2.7/lib-tk/Tkinter.py", line 42, in <module>
raise ImportError, str(msg) + ', please install the python-tk package'
ImportError: No module named _tkinter, please install the python-tk package
I think I have solved this one before but forget how I did it.
I am working on computer with Ubuntu 16.04.
I have anaconda installed and was using the jupyter notebook just fine both for julia and python a couple of hours while ago. I installed/reinstalled some packages but nothing out of the ordinary.
However, after closing notebooks and then trying to open them again I get error:
jupyter notebook
Traceback (most recent call last):
File "/home/user/anaconda2/bin/jupyter-notebook", line 4, in <module>
import notebook.notebookapp
File "/home/user/anaconda2/lib/python2.7/site-packages/notebook/notebookapp.py", line 60, in <module>
from .services.contents.manager import ContentsManager
File "/home/user/anaconda2/lib/python2.7/site-packages/notebook/services/contents/manager.py", line 16, in <module>
from nbformat import sign, validate, ValidationError
File "/home/user/anaconda2/lib/python2.7/site-packages/nbformat/__init__.py", line 33, in <module>
from .validator import validate, ValidationError
File "/home/user/anaconda2/lib/python2.7/site-packages/nbformat/validator.py", line 12, in <module>
from jsonschema import ValidationError
File "/home/user/anaconda2/lib/python2.7/site-packages/jsonschema/__init__.py", line 18, in <module>
from jsonschema.validators import (
File "/home/user/anaconda2/lib/python2.7/site-packages/jsonschema/validators.py", line 8, in <module>
import requests
File "/home/user/anaconda2/lib/python2.7/site-packages/requests/__init__.py", line 52, in <module>
from .packages.urllib3.contrib import pyopenssl
File "/home/user/anaconda2/lib/python2.7/site-packages/requests/packages/urllib3/contrib/pyopenssl.py", line 46, in <module>
import OpenSSL.SSL
File "/home/user/anaconda2/lib/python2.7/site-packages/OpenSSL/__init__.py", line 8, in <module>
from OpenSSL import rand, crypto, SSL
File "/home/user/anaconda2/lib/python2.7/site-packages/OpenSSL/rand.py", line 11, in <module>
from OpenSSL._util import (
File "/home/user/anaconda2/lib/python2.7/site-packages/OpenSSL/_util.py", line 7, in <module>
binding = Binding()
File "/home/user/anaconda2/lib/python2.7/site-packages/cryptography/hazmat/bindings/openssl/binding.py", line 89, in __init__
self._ensure_ffi_initialized()
File "/home/user/anaconda2/lib/python2.7/site-packages/cryptography/hazmat/bindings/openssl/binding.py", line 109, in _ensure_ffi_initialized
libraries=libraries,
File "/home/user/anaconda2/lib/python2.7/site-packages/cryptography/hazmat/bindings/utils.py", line 80, in build_ffi
extra_link_args=extra_link_args,
File "/home/user/anaconda2/lib/python2.7/site-packages/cffi/api.py", line 437, in verify
lib = self.verifier.load_library()
File "/home/user/anaconda2/lib/python2.7/site-packages/cffi/verifier.py", line 114, in load_library
return self._load_library()
File "/home/user/anaconda2/lib/python2.7/site-packages/cffi/verifier.py", line 225, in _load_library
return self._vengine.load_library()
File "/home/user/anaconda2/lib/python2.7/site-packages/cffi/vengine_cpy.py", line 158, in load_library
raise ffiplatform.VerificationError(error)
cffi.ffiplatform.VerificationError: importing '/home/user/anaconda2/lib/python2.7/site-packages/cryptography/_Cryptography_cffi_4ed9e37dx4000d087.so': /home/user/anaconda2/lib/python2.7/site-packages/cryptography/_Cryptography_cffi_4ed9e37dx4000d087.so: undefined symbol: SSLv2_client_method
I think this has to do with anaconda since the following comands will trigger the same error.
conda install jupyter
pip install jupyter
pip install python-igraph
I have already installed the libraries suggested by the answers to this question (meet cffi.ffiplatform.VerificationError when install pyopenssl). But it hasn't worked.
I created a virtualenv with virtualenv env, and then (after sourcing env/bin/activate) installed pusher with pip. However, whenever I try to run my module, I get this error:
Traceback (most recent call last):
File "/home/proc-daemon/google_appengine/google/appengine/runtime/wsgi.py", line 240, in Handle
handler = _config_handle.add_wsgi_middleware(self._LoadHandler())
File "/home/proc-daemon/google_appengine/google/appengine/runtime/wsgi.py", line 299, in _LoadHandler
handler, path, err = LoadObject(self._handler)
File "/home/proc-daemon/google_appengine/google/appengine/runtime/wsgi.py", line 85, in LoadObject
obj = __import__(path[0])
File "/home/proc-daemon/supachat/supachat.py", line 31, in <module>
ssl=True
File "/home/proc-daemon/supachat/env/lib/python2.7/site-packages/pusher/pusher.py", line 52, in __init__
json_encoder, json_decoder, backend, **backend_options)
File "/home/proc-daemon/supachat/env/lib/python2.7/site-packages/pusher/pusher_client.py", line 34, in __init__
json_encoder, json_decoder, backend, **backend_options)
File "/home/proc-daemon/supachat/env/lib/python2.7/site-packages/pusher/client.py", line 20, in __init__
from .requests import RequestsBackend
File "/home/proc-daemon/supachat/env/lib/python2.7/site-packages/pusher/requests.py", line 17, in <module>
import urllib3.contrib.pyopenssl
File "/home/proc-daemon/supachat/env/lib/python2.7/site-packages/urllib3/contrib/pyopenssl.py", line 46, in <module>
import OpenSSL.SSL
File "/home/proc-daemon/supachat/env/lib/python2.7/site-packages/OpenSSL/__init__.py", line 8, in <module>
from OpenSSL import crypto, SSL
File "/home/proc-daemon/supachat/env/lib/python2.7/site-packages/OpenSSL/crypto.py", line 12, in <module>
from cryptography import x509
File "/home/proc-daemon/supachat/env/lib/python2.7/site-packages/cryptography/x509/__init__.py", line 7, in <module>
from cryptography.x509 import certificate_transparency
ImportError: cannot import name certificate_transparency
All the dependencies installed correctly, and ls env/lib/python2.7/site-packages/cryptography/x509 shows (among others) certificate_transparency.pyc (and .py).
Is there a different way to install pusher that I am not realizing?
So, this doesn't explain the problem, but it solves it.
I was using the wrong backend. Importing pusher.gae and setting backend=pusher.gae.GAEBackend solved the problem.
I somehow messed up my python and am running out of ideas how to fix it. I am using Python 2.7.6. on a Windows computer. Basically anything connected to xml stopped working. Meaning: it worked fine before, then the console crashed, and now I get the error described.
When I write
pip install numpy
in the console I get the following error:
Traceback (most recent call last):
File "C:\Python27\Scripts\pip-script.py", line 9, in <module>
load_entry_point('pip==1.5.2', 'console_scripts', 'pip')()
File "C:\Python27\lib\site-packages\pkg_resources.py", line 351, in load_entry
_point
return get_distribution(dist).load_entry_point(group, name)
File "C:\Python27\lib\site-packages\pkg_resources.py", line 2363, in load_entr
y_point
return ep.load()
File "C:\Python27\lib\site-packages\pkg_resources.py", line 2088, in load
entry = __import__(self.module_name, globals(),globals(), ['__name__'])
File "C:\Python27\lib\site-packages\pip\__init__.py", line 11, in <module>
from pip.vcs import git, mercurial, subversion, bazaar # noqa
File "C:\Python27\lib\site-packages\pip\vcs\subversion.py", line 4, in <module
>
from pip.index import Link
File "C:\Python27\lib\site-packages\pip\index.py", line 18, in <module>
import html5lib
File "C:\Python27\lib\site-packages\html5lib\__init__.py", line 16, in <module
>
from .html5parser import HTMLParser, parse, parseFragment
File "C:\Python27\lib\site-packages\html5lib\html5parser.py", line 6, in <modu
le>
from . import inputstream
File "C:\Python27\lib\site-packages\html5lib\inputstream.py", line 10, in <mod
ule>
from . import utils
File "C:\Python27\lib\site-packages\html5lib\utils.py", line 8, in <module>
import xml.etree.ElementTree as default_etree
ImportError: No module named etree.ElementTree
What I did so far: I tried to reinstall the xml package (which was suggested in the forum). I also installed Anaconda with various environments. There, the problem is visible when I want to use packages like openpyxl, which gives me a similar error message:
Traceback (most recent call last):
File "HU_calc.py", line 1, in <module>
import openpyxl as px
File "D:\anaconda3\envs\py278\lib\site-packages\openpyxl\__init__.py", line 29
, in <module>
from openpyxl.workbook import Workbook
File "D:\anaconda3\envs\py278\lib\site-packages\openpyxl\workbook\__init__.py"
, line 5, in <module>
from .workbook import Workbook
File "D:\anaconda3\envs\py278\lib\site-packages\openpyxl\workbook\workbook.py"
, line 7, in <module>
from openpyxl.worksheet import Worksheet
File "D:\anaconda3\envs\py278\lib\site-packages\openpyxl\worksheet\__init__.py
", line 4, in <module>
from .worksheet import Worksheet
File "D:\anaconda3\envs\py278\lib\site-packages\openpyxl\worksheet\worksheet.p
y", line 35, in <module>
from openpyxl.cell import Cell
File "D:\anaconda3\envs\py278\lib\site-packages\openpyxl\cell\__init__.py", li
ne 4, in <module>
from .cell import Cell, WriteOnlyCell
File "D:\anaconda3\envs\py278\lib\site-packages\openpyxl\cell\cell.py", line 4
5, in <module>
from openpyxl.styles import numbers, is_date_format
File "D:\anaconda3\envs\py278\lib\site-packages\openpyxl\styles\__init__.py",
line 5, in <module>
from .alignment import Alignment
File "D:\anaconda3\envs\py278\lib\site-packages\openpyxl\styles\alignment.py",
line 6, in <module>
from openpyxl.descriptors import Bool, MinMax, Min, Alias, NoneSet
File "D:\anaconda3\envs\py278\lib\site-packages\openpyxl\descriptors\__init__.
py", line 5, in <module>
from .sequence import Sequence
File "D:\anaconda3\envs\py278\lib\site-packages\openpyxl\descriptors\sequence.
py", line 5, in <module>
from openpyxl.xml.functions import Element
File "D:\anaconda3\envs\py278\lib\site-packages\openpyxl\xml\functions.py", li
ne 28, in <module>
from xml.etree.cElementTree import iterparse
ImportError: No module named etree.cElementTree
This is especially confusing to me, as I thought Anaconda would create a python environment completely isolated from the Windows one. I feel like I am missing something very obvious. If there's anything missing/unclear in my question, I'll fix that as soon as possible.
I'd be very grateful for every advice.
Looks like you have a python script named xml.py. Rename that and it should work.
I am on OSX 10.10.3 with Python 2.7.6 as my main Python. I suddenly ran into trouble using pip, and tried to fix it. The solution proposed elsewhere on StackOverflow was to remove installations of pip and reinstall it either using their official installer or using easy_install.
Running the installation script (https://bootstrap.pypa.io/get-pip.py) gives:
Traceback (most recent call last):
File "pip.py", line 17767, in <module>
main()
File "pip.py", line 162, in main
bootstrap(tmpdir=tmpdir)
File "pip.py", line 82, in bootstrap
import pip
File "/tmp/tmpDnRtQK/pip.zip/pip/__init__.py", line 6, in <module>
File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/optparse.py", line 90, in <module>
from gettext import gettext
File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/gettext.py", line 49, in <module>
import locale, copy, os, re, struct, sys
File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/locale.py", line 110, in <module>
#functools.wraps(_localeconv)
AttributeError: 'module' object has no attribute 'wraps'
and running "sudo easy_install pip" gives
Traceback (most recent call last):
File "/usr/bin/easy_install-2.7", line 7, 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 581, in resolve
requirements.extend(dist.requires(req.extras)[::-1])
File "/System/Library/Frameworks/Python.framework/Versions/2.7/Extras/lib/python/pkg_resources.py", line 2323, in requires
dm = self._dep_map
File "/System/Library/Frameworks/Python.framework/Versions/2.7/Extras/lib/python/pkg_resources.py", line 2374, in __getattr__
raise AttributeError(attr)
AttributeError: _dep_map
I am not really sure where to go next.
I am also in the situation that I can't import various modules, for example Flask, since I get the following error:
Traceback (most recent call last):
File "/Users/dawi/git/friends/run.py", line 2, in <module>
from application import app
File "/Users/dawi/git/friends/application/__init__.py", line 3, in <module>
from flask import Flask
File "/Library/Python/2.7/site-packages/Flask-0.10.1-py2.7.egg/flask/__init__.py", line 17, in <module>
from werkzeug.exceptions import abort
File "/Library/Python/2.7/site-packages/Werkzeug-0.9.6-py2.7.egg/werkzeug/__init__.py", line 154, in <module>
__import__('werkzeug.exceptions')
File "/Library/Python/2.7/site-packages/Werkzeug-0.9.6-py2.7.egg/werkzeug/exceptions.py", line 71, in <module>
from werkzeug.wrappers import Response
File "/Library/Python/2.7/site-packages/Werkzeug-0.9.6-py2.7.egg/werkzeug/wrappers.py", line 23, in <module>
from functools import update_wrapper
ImportError: cannot import name update_wrapper