Tensorflow error while importing in Python 2.7 - python-2.7

I have Python 2.7 on MacOS.
I have built Tensorflow from the source using bazel as below:
bazel build --config=opt //tensorflow/tools/pip_package:build_pip_package
I am getting the below error while I am trying to import the Tensorflow package.
import tensorflow as tf
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "tensorflow/__init__.py", line 24, in <module>
from tensorflow.python import *
File "tensorflow/python/__init__.py", line 49, in <module>
from tensorflow.python import pywrap_tensorflow
File "tensorflow/python/pywrap_tensorflow.py", line 52, in <module>
raise ImportError(msg)
ImportError: Traceback (most recent call last):
File "tensorflow/python/pywrap_tensorflow.py", line 41, in <module>
from tensorflow.python.pywrap_tensorflow_internal import *
ImportError: No module named pywrap_tensorflow_internal

After installing using pip it worked.
$ sudo pip install /tmp/tensorflow_pkg/tensorflow-1.1.0-py2-none-any.whl

Related

ImportError: cannot import name _remove_dead_weakref in django virtualenv

After upgrading my Ubuntu desktop to 18.04 from 16.04, the django's virtualenv refuses to start:
(.djangoenv) mw#desktop:~/theapp$ python manage.py runserver
Traceback (most recent call last):
File "manage.py", line 8, in <module>
from django.core.management import execute_from_command_line
File "/home/mw/.djangoenv/local/lib/python2.7/site-packages/django/core/management/__init__.py", line 10, in <module>
from django.apps import apps
File "/home/mw/.djangoenv/local/lib/python2.7/site-packages/django/apps/__init__.py", line 1, in <module>
from .config import AppConfig # NOQA
File "/home/mw/.djangoenv/local/lib/python2.7/site-packages/django/apps/config.py", line 4, in <module>
from django.core.exceptions import AppRegistryNotReady, ImproperlyConfigured
File "/home/mw/.djangoenv/local/lib/python2.7/site-packages/django/core/exceptions.py", line 5, in <module>
from django.utils.encoding import force_text
File "/home/mw/.djangoenv/local/lib/python2.7/site-packages/django/utils/encoding.py", line 10, in <module>
from django.utils.functional import Promise
File "/home/mw/.djangoenv/local/lib/python2.7/site-packages/django/utils/functional.py", line 1, in <module>
import copy
File "/usr/lib/python2.7/copy.py", line 52, in <module>
import weakref
File "/usr/lib/python2.7/weakref.py", line 14, in <module>
from _weakref import (
ImportError: cannot import name _remove_dead_weakref
On the djangoenv and outside it
$ python --version :
`Python 2.7.12`
Hoping to resolve the issue, I also install Python 2.7.16 on the desktop, so I get:
$ python2.7 --version
Python 2.7.16
Also when I try to install new virtualenv, I get the same error:
$ virtualenv .blaenv
Running virtualenv with interpreter /home/mw/.djangoenv/bin/python2
Traceback (most recent call last):
File "/usr/lib/python3/dist-packages/virtualenv.py", line 21, in <module>
import logging
File "/usr/lib/python2.7/logging/__init__.py", line 26, in <module>
import sys, os, time, cStringIO, traceback, warnings, weakref, collections
File "/usr/lib/python2.7/weakref.py", line 14, in <module>
from _weakref import (
ImportError: cannot import name _remove_dead_weakref
Answers to the same error in other contexts did not help and my search led to no more clues.
So really appreciate your hints.
As per https://askubuntu.com/questions/981663/python2-7-broken-by-weakref-import-error-please-help you probably need to recreate your virtualenv. I suspect your problem here is that you need to deactivate your current env before you try to make the new one, in order to ensure that your system python2 interpreter is the one running the virtualenv command.

Cannot import _uuid_generate_random when trying to import carrot.connection

I have a requirement of using the carrot python library. This is the code code.
from carrot.connection import BrokerConnection
from carrot.messaging import Consumer
Both the lines are throwing an ImportError exception.
The exception traceback is..
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/.virtualenvs/stack/lib/python2.7/site-packages/carrot/connection.py", line 14, in <module>
from carrot.backends import get_backend_cls
File "/.virtualenvs/stack/lib/python2.7/site packages/carrot/backends/__init__.py", line 8, in <module>
from carrot.utils import rpartition
File "/.virtualenvs/stack/lib/python2.7/site-packages/carrot/utils.py", line 1, in <module>
from uuid import UUID, uuid4, _uuid_generate_random
ImportError: cannot import name _uuid_generate_random
Im running this on Python 2.7.13 with the latest version of carrot and uuid. I have also tried upgrading uuid.

Installed georasters successfully but unable to import it

I installed georasters using "pip install georasters".But I am unable to import it in python.The following error comes:
Traceback (most recent call last):
File "<pyshell#0>", line 1, in <module>
import georasters
File "D:\Python\lib\site-packages\georasters\__init__.py", line 3, in <module>
from .georasters import get_geo_info, map_pixel, map_pixel_inv, aggregate, create_geotiff, align_rasters, \
File "D:\Python\lib\site-packages\georasters\georasters.py", line 37, in <module>
import pandas as pd
File "D:\Python\lib\site-packages\pandas\__init__.py", line 25, in <module>
from pandas import hashtable, tslib, lib
File "pandas\src\numpy.pxd", line 157, in init pandas.hashtable (pandas\hashtable.c:38509)
ValueError: numpy.dtype has the wrong size, try recompiling
Kindly clarify.

cannot import pybrain module in python 2.7

I followed the exact documentation in here
but after that importing produces the following error. I am using windows 7 and python 2.7. I have already installed scipy and matplotlib.
The error that I get is as follows:
>>> import pybrain
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "pybrain\__init__.py", line 1, in <module>
from pybrain.structure.__init__ import *
File "pybrain\structure\__init__.py", line 2, in <module>
from pybrain.structure.modules.__init__ import *
File "pybrain\structure\modules\__init__.py", line 2, in <module>
from pybrain.structure.modules.gate import GateLayer, DoubleGateLayer, Multi
plicationLayer, SwitchLayer
File "pybrain\structure\modules\gate.py", line 10, in <module>
from pybrain.tools.functions import sigmoid, sigmoidPrime
File "pybrain\tools\functions.py", line 4, in <module>
from scipy.linalg import inv, det, svd, logm, expm2
File "C:\Python27\lib\site-packages\scipy\linalg\__init__.py", line 174, in <m
odule>
from .misc import *
File "C:\Python27\lib\site-packages\scipy\linalg\misc.py", line 5, in <module>
from .blas import get_blas_funcs
File "C:\Python27\lib\site-packages\scipy\linalg\blas.py", line 155, in <modul
e>
from scipy.linalg import _fblas
ImportError: DLL load failed: The specified module could not be found.
For scipy requires installing numpy+mkl. You can install this lib from http://www.lfd.uci.edu/~gohlke/pythonlibs/#numpy

Cant get ipython to run

I installed ipynotebook using pip and get this error everytime i try to start ipython notebook using terminal (ubuntu 14.04)
siddharth#siddharth-HP-Pavilion-g6-Notebook-PC:~$ ipython notebook
Traceback (most recent call last):
File "/usr/local/bin/ipython", line 7, in <module>
from IPython import start_ipython
File "/usr/local/lib/python2.7/dist-packages/IPython/__init__.py", line 47, in <module>
from .core.application import Application
File "/usr/local/lib/python2.7/dist-packages/IPython/core/application.py", line 22, in <module>
from traitlets.config.application import Application, catch_config_error
File "/usr/local/lib/python2.7/dist-packages/traitlets/config/__init__.py", line 6, in <module>
from .application import *
File "/usr/local/lib/python2.7/dist-packages/traitlets/config/application.py", line 17, in <module>
from decorator import decorator
ImportError: No module named decorator
What should I do?