System information
Linux Ubuntu 16.04
TensorFlow version: tensorflow-gpu 1.5
Python version: 2.7
Installed using virtualenv: pip
CUDA/cuDNN version: CUDA9.0 & CUDNN7.0
Enviroment
Using anaconda to create a virtual environment named tf.
Error Msg
(tf) ➜ ~ python
Python 2.7.18 |Anaconda, Inc.| (default, Jun 4 2021, 14:47:46)
[GCC 7.3.0] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> import tensorflow as tf
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/home/xander/anaconda3/envs/tf/lib/python2.7/site-packages/tensorflow/__init__.py", line 24, in <module>
from tensorflow.python import *
File "/home/xander/anaconda3/envs/tf/lib/python2.7/site-packages/tensorflow/python/__init__.py", line 52, in <module>
from tensorflow.core.framework.graph_pb2 import *
File "/home/xander/anaconda3/envs/tf/lib/python2.7/site-packages/tensorflow/core/framework/graph_pb2.py", line 6, in <module>
from google.protobuf import descriptor as _descriptor
File "/home/xander/anaconda3/envs/tf/lib/python2.7/site-packages/google/protobuf/descriptor.py", line 113
class DescriptorBase(metaclass=DescriptorMetaclass):
^
SyntaxError: invalid syntax
>>> import tensorflow as tf
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/home/xander/anaconda3/envs/tf/lib/python2.7/site-packages/tensorflow/__init__.py", line 24, in <module>
from tensorflow.python import *
File "/home/xander/anaconda3/envs/tf/lib/python2.7/site-packages/tensorflow/python/__init__.py", line 49, in <module>
from tensorflow.python import pywrap_tensorflow
ImportError: cannot import name pywrap_tensorflow
As mentioned in this link, You're running the script in the same directory as TensorFlow. Try to move it out and you should be fine.
For example, Open the Linux command line and execute the script that you've just copied to desktop
Restarting the conda (using miniconda + conda-forge channel) works for me. But I don't know why, though...
Related
I'm on windows 10, I'm getting this error but cant see any helpful clue to fix this. I'm trying to install tensorflow and my python version is 3.6. Can any one help me to fix this.
(venv) D:\Work\IIT\Fourth Year\Submission\FYP\FYP Project\FYPProject>python
Python 3.6.0 (v3.6.0:41df79263a11, Dec 23 2016, 08:06:12) [MSC v.1900 64 bit (AMD64)] on win32
Type "help", "copyright", "credits" or "license" for more information.
>>> import tensorflow as tf
2020-02-03 08:25:40.694788: I tensorflow/stream_executor/platform/default/dso_loader.cc:44] Successfully opened
dynamic library cudart64_101.dll
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "D:\Work\IIT\Fourth Year\Submission\FYP\FYP
Project\FYPProject\venv\lib\site-packages\tensorflow\__init__.py", line 101, in <module>
from tensorflow_core import *
File "D:\Work\IIT\Fourth Year\Submission\FYP\FYP
Project\FYPProject\venv\lib\site-packages\tensorflow_core\__init__.py", line 40, in <module>
from tensorflow.python.tools import module_util as _module_util
File "D:\Work\IIT\Fourth Year\Submission\FYP\FYP
Project\FYPProject\venv\lib\site-packages\tensorflow\__init__.py", line 50, in __getattr__
module = self._load()
File "D:\Work\IIT\Fourth Year\Submission\FYP\FYP
Project\FYPProject\venv\lib\site-packages\tensorflow\__init__.py", line 44, in _load
module = _importlib.import_module(self.__name__)
File "D:\Work\IIT\Fourth Year\Submission\FYP\FYP
Project\FYPProject\venv\lib\importlib\__init__.py", line 126, in import_module
return _bootstrap._gcd_import(name[level:], package, level)
File "D:\Work\IIT\Fourth Year\Submission\FYP\FYP Project\FYPProject\venv\lib\site-packages\tensorflow_core\python\__init__.py", line 64, in <module>
from tensorflow.core.framework.graph_pb2 import *
File "D:\Work\IIT\Fourth Year\Submission\FYP\FYP Project\FYPProject\venv\lib\site-packages\tensorflow_core\core\framework\graph_pb2.py", line 7, in <module>
from google.protobuf import descriptor as _descriptor
File "D:\Work\IIT\Fourth Year\Submission\FYP\FYP
Project\FYPProject\venv\lib\site-packages\google\protobuf\descriptor.py", line 47, in <module>
from google.protobuf.pyext import _message
ImportError: DLL load failed: The specified procedure could not be found.
>>>
So far I have found this. First uninstall the existing tensorflow using
pip uninstall tensorflow
And install again using this,
pip install tensorflow==1.5
pip install protobuf==3.6.0
if the 'tf_utils' error come you can try this,
pip install keras==2.1.5
I am trying to install Tensorflow 1.14 and Keras 2.0 but it keeps giving me an issue when I try to import it. It seems to install correctly but then just fails.
I am running Pi 3b+ Linux raspberrypi 4.19.75-v7+ #1270 SMP Tue Sep 24 18:45:11 BST 2019 armv7l GNU/Linux
The error it is giving me is:
>>> import tensorflow as tf
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/home/pi/cvenv/lib/python3.5/site-packages/tensorflow/__init__.py", line 28, in <module>
from tensorflow.python import pywrap_tensorflow # pylint: disable=unused-import
File "/home/pi/cvenv/lib/python3.5/site-packages/tensorflow/python/__init__.py", line 47, in <module>
import numpy as np
File "/home/pi/cvenv/lib/python3.5/site-packages/numpy/__init__.py", line 150, in <module>
from . import random
File "/home/pi/cvenv/lib/python3.5/site-packages/numpy/random/__init__.py", line 181, in <module>
from . import _pickle
File "/home/pi/cvenv/lib/python3.5/site-packages/numpy/random/_pickle.py", line 1, in <module>
from .mtrand import RandomState
ImportError: /home/pi/cvenv/lib/python3.5/site-packages/numpy/random/mtrand.cpython-35m-arm-linux-gnueabihf.so: undefined symbol: PyFPE_jbuf
You need to install libatlas to make numpy work
sudo apt install libatlas3-base
I created an environment (radIOenv) in Anaconda.
And I typed python -m pip install git+https://github.com/analysiscenter/radio.git.
When i type import radio or from radio import CTImagesBatch I get the following error : ModuleNotFoundError: No module named 'blosc.blosc_extension'
How can I solve this problem ?
Here is the full output :
(radIOenv) C:\Users\user>python -m pip install git+https://github.com/analysiscenter/radio.git
Collecting git+https://github.com/analysiscenter/radio.git
Cloning https://github.com/analysiscenter/radio.git to c:\users\user\appdata\local\temp\pip-req-build-4ii04ktu
Requirement already satisfied (use --upgrade to upgrade): radio==0.1.0 from git+https://github.com/analysiscenter/radio.git in c:\users\user\anaconda3\envs\radioenv\lib\site-packages
Requirement already satisfied: numpy>=1.10 in c:\users\user\anaconda3\envs\radioenv\lib\site-packages (from radio==0.1.0) (1.16.2)
Requirement already satisfied: pandas>=0.21.0 in c:\users\user\anaconda3\envs\radioenv\lib\site-packages (from radio==0.1.0) (0.24.1)
...
Successfully built radio
(radIOenv) C:\Users\user>python
Python 3.7.1 | packaged by conda-forge | (default, Feb 26 2019, 04:46:14) [MSC v.1900 64 bit (AMD64)] :: Anaconda, Inc. on win32
Type "help", "copyright", "credits" or "license" for more information.
>>> import radio
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "C:\Users\user\Anaconda3\envs\radIOenv\lib\site-packages\radio\__init__.py", line 5, in <module>
from .preprocessing import *
File "C:\Users\user\Anaconda3\envs\radIOenv\lib\site-packages\radio\preprocessing\__init__.py", line 3, in <module>
from .ct_batch import CTImagesBatch
File "C:\Users\user\Anaconda3\envs\radIOenv\lib\site-packages\radio\preprocessing\ct_batch.py", line 15, in <module>
import blosc
File "C:\Users\user\Anaconda3\envs\radIOenv\lib\site-packages\blosc\__init__.py", line 13, in <module>
from blosc.blosc_extension import (
ModuleNotFoundError: No module named 'blosc.blosc_extension'
>>> from radio import CTImagesBatch
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "C:\Users\user\Anaconda3\envs\radIOenv\lib\site-packages\radio\__init__.py", line 5, in <module>
from .preprocessing import *
File "C:\Users\user\Anaconda3\envs\radIOenv\lib\site-packages\radio\preprocessing\__init__.py", line 3, in <module>
from .ct_batch import CTImagesBatch
File "C:\Users\user\Anaconda3\envs\radIOenv\lib\site-packages\radio\preprocessing\ct_batch.py", line 15, in <module>
import blosc
File "C:\Users\user\Anaconda3\envs\radIOenv\lib\site-packages\blosc\__init__.py", line 13, in <module>
from blosc.blosc_extension import (
ModuleNotFoundError: No module named 'blosc.blosc_extension'
I've had an issue in Anaconda before where I've accidentally installed the C version of Blosc rather than the Python version. I doubt this is your issue but the Python version is installed with conda install -c conda-forge python-blosc
I know tensorflow-gpu==1.12 needs CUDA 9.0 or lesser but is there any possibility where I can install Tensorflow on CUDA 10.0? May be via source or using Bazel?
UPDATE: I tried downloading from Github and installing via Bazel but I get the following Error.
Python 3.7.1 (default, Oct 23 2018, 19:19:42)
[GCC 7.3.0] :: Anaconda, Inc. on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import tensorflow
Traceback (most recent call last):
File "/some-folder/tensorflow-1.12.0/tensorflow/python/platform/self_check.py", line 25, in <module>
from tensorflow.python.platform import build_info
ImportError: cannot import name 'build_info' from 'tensorflow.python.platform' (unknown location)
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/some-folder/tensorflow-1.12.0/tensorflow/__init__.py", line 24, in <module>
from tensorflow.python import pywrap_tensorflow # pylint: disable=unused-import
File "/some-folder/tensorflow-1.12.0/tensorflow/python/__init__.py", line 49, in <module>
from tensorflow.python import pywrap_tensorflow
File "/some-folder/tensorflow-1.12.0/tensorflow/python/pywrap_tensorflow.py", line 25, in <module>
from tensorflow.python.platform import self_check
File "/some-folder/tensorflow-1.12.0/tensorflow/python/platform/self_check.py", line 27, in <module>
raise ImportError("Could not import tensorflow. Do not import tensorflow "
ImportError: Could not import tensorflow. Do not import tensorflow from its source directory; change directory to outside the TensorFlow source tree, and relaunch your Python interpreter from there.
tensorflow doesn't support python 3.7 version.
Requires Python 3.4, 3.5, or 3.6
see below
https://www.tensorflow.org/install/pip
We need to just come out of the Source Directory and run the python file. If you are running a file with python filename.py command you need to shift the file outside the source directory.
When you use import tensorflow from the source directory it will import the folder tensorflow and not the actual tensorflow library
Trying to use the rpy2.ipython (formerly 'rmagic') extension of IPython, to get interactive R (%R line magic and %%R cell magic functions), I get the following errors...
louis ~ $ python
Python 3.5.1 |Anaconda 2.4.0 (64-bit)| (default, Dec 7 2015, 11:16:01)
[GCC 4.4.7 20120313 (Red Hat 4.4.7-1)] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import rpy2.ipython
Traceback (most recent call last):
File "/home/louis/anaconda3/lib/python3.5/site-packages/pandas/__init__.py", line 7, in <module>
from pandas import hashtable, tslib, lib
File "pandas/src/numpy.pxd", line 157, in init pandas.hashtable (pandas/hashtable.c:38262)
File "/home/louis/anaconda3/lib/python3.5/site-packages/numpy/__init__.py", line 180, in <module>
from . import add_newdocs
File "/home/louis/anaconda3/lib/python3.5/site-packages/numpy/add_newdocs.py", line 13, in <module>
from numpy.lib import add_newdoc
File "/home/louis/anaconda3/lib/python3.5/site-packages/numpy/lib/__init__.py", line 18, in <module>
from .polynomial import *
File "/home/louis/anaconda3/lib/python3.5/site-packages/numpy/lib/polynomial.py", line 20, in <module>
from numpy.linalg import eigvals, lstsq, inv
File "/home/louis/anaconda3/lib/python3.5/site-packages/numpy/linalg/__init__.py", line 51, in <module>
from .linalg import *
File "/home/louis/anaconda3/lib/python3.5/site-packages/numpy/linalg/linalg.py", line 29, in <module>
from numpy.linalg import lapack_lite, _umath_linalg
ImportError: /home/louis/anaconda3/lib/python3.5/site-packages/numpy/linalg/lapack_lite.cpython-35m-x86_64-linux-gnu.so: undefined symbol: zgelsd_
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "/home/louis/anaconda3/lib/python3.5/site-packages/rpy2/ipython/rmagic.py", line 59, in <module>
from rpy2.robjects import pandas2ri as baseconversion
File "/home/louis/anaconda3/lib/python3.5/site-packages/rpy2/robjects/pandas2ri.py", line 6, in <module>
from pandas.core.frame import DataFrame as PandasDataFrame
File "/home/louis/anaconda3/lib/python3.5/site-packages/pandas/__init__.py", line 13, in <module>
"extensions first.".format(module))
ImportError: C extension: /home/louis/anaconda3/lib/python3.5/site-packages/numpy/linalg/lapack_lite.cpython-35m-x86_64-linux-gnu.so: undefined symbol: zgelsd_ not built. If you want to import pandas from the source directory, you may need to run 'python setup.py build_ext --inplace' to build the C extensions first.
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/home/louis/anaconda3/lib/python3.5/site-packages/rpy2/ipython/__init__.py", line 1, in <module>
from .rmagic import load_ipython_extension
File "/home/louis/anaconda3/lib/python3.5/site-packages/rpy2/ipython/rmagic.py", line 63, in <module>
from rpy2.robjects import numpy2ri as baseconversion
File "/home/louis/anaconda3/lib/python3.5/site-packages/rpy2/robjects/numpy2ri.py", line 6, in <module>
import numpy
File "/home/louis/anaconda3/lib/python3.5/site-packages/numpy/__init__.py", line 180, in <module>
from . import add_newdocs
File "/home/louis/anaconda3/lib/python3.5/site-packages/numpy/add_newdocs.py", line 13, in <module>
from numpy.lib import add_newdoc
File "/home/louis/anaconda3/lib/python3.5/site-packages/numpy/lib/__init__.py", line 18, in <module>
from .polynomial import *
File "/home/louis/anaconda3/lib/python3.5/site-packages/numpy/lib/polynomial.py", line 13, in <module>
import numpy.core.numeric as NX
AttributeError: module 'numpy' has no attribute 'core'
I've always ignored the fact that Anaconda3 seems to have been built on RHEL (I'm on Linux Mint, which is based on Ubuntu), but I'm wondering now if this might be the cause of the problem here - "C extensions not built" for my machine?
Since it's in the conda virtual environment, I'm not sure how I can fix this.
Should I attempt to python setup.py build_ext --inplace within ~/anaconda3/lib/python3.5/site-packages/pandas ?
When I step through the above imports, of e.g. :
from numpy.linalg import lapack_lite, _umath_linalg
there's no error, so I'm not certain there are actually unbuilt files, perhaps it's just some masking of one variable by another (as in this question with similar error message but different traceback, i.e. an error in rpy2).
import numpy.core (etc.) without first trying to load rpy2.ipython works fine
Summary of pip show :
---
Metadata-Version: 2.0
Name: rpy2
Version: 2.7.5
---
Metadata-Version: 1.1
Name: numpy
Version: 1.10.1
---
Metadata-Version: 1.1
Name: pandas
Version: 0.17.0
---
Metadata-Version: 2.0
Name: ipython
Version: 4.0.1
(all locations /home/louis/anaconda3/lib/python3.5/site-packages)
System info from cat /proc/version and lsb_release -a :
Linux version 3.13.0-35-generic (buildd#panlong) (gcc version 4.8.2 (Ubuntu 4.8.2-19ubuntu1) ) #62-Ubuntu SMP Fri Aug 15 01:58:42 UTC 2014
LSB Version: core-2.0-amd64:core-2.0-noarch:core-3.0-amd64:core-3.0-noarch:core-3.1-amd64:core-3.1-noarch:core-3.2-amd64:core-3.2-noarch:core-4.0-amd64:core-4.0-noarch:core-4.1-amd64:core-4.1-noarch
Description: Linux Mint 17 Qiana
I am suspecting an incompatibility between versions of the LAPACK library: the one picked at runtime on your system, the one numpy was built with, and the one R was built with.
Installing numpy, R, and rpy2 from source in your virtual environment should solve the issue. An alternative would be to notify the maintainers of the anaconda packages involved and see it they confirm that numpy and R packaged by anaconda use the same LAPACK.