I am trying to setup Tensorflow, and using Anaconda. I installed Tensorflow within the Anaconda environment, but cannot locate the Tensorflow packages in my Python library.
I have been following the setup instructions here, and had no issues running print(sess.run(hello)). However, in the next step, it asks to locate the MNIST package(s). When I run the command below, I get what I assume is the path to the tensorflow packages:
(tensorflow) adamg:TensorFlow adamg$ python -c 'import os; import inspect; import tensorflow; print(os.path.dirname(inspect.getfile(tensorflow)))'
/Users/adamg/anaconda/envs/tensorflow/lib/python3.5/site-packages/tensorflow
Using that path, I then tried to run both:
python -m tensorflow.models.image.mnist.convolutional
and
python /Users/adamg/anaconda/envs/tensorflow/lib/python3.5/site-packages/tensorflow/models/image/mnist/convolutional.py
but received the error:
python: can't open file '/Users/adamg/anaconda/envs/tensorflow/lib/python3.5/site-packages/tensorflow/models/image/mnist/convolutional.py': [Errno 2] No such file or directory
How can I locate the correct directory?
Related
I am running Windows 10, and I have Python installed.
When trying to run a Python program with the line from sklearn.cluster import DBSCAN in it, I get the following error:
File "C:\Users\User\AppData\Local\Programs\Python\Python310\lib\site-packages\sklearn\metrics\pairwise.py", line 33, in <module>
from ._pairwise_distances_reduction import PairwiseDistancesArgKmin
ImportError: DLL load failed while importing _pairwise_distances_reduction: The specified module could not be found.
I have tried solving this by entering each of these in the command line (separately, not all at once) and checking whether or the program works:
pip install sklearn
pip install scikit-learn
pip uninstall scipy then pip install scipy
pip uninstall numpy then pip install numpy
I still get the same error when running the program. I'm having difficulty troubleshooting this, searching for "_pairwise_distances_reduction" returns no helpful results.
Is there something I'm supposed to install that I missed?
I was having this problem too, I installed Visual C++ Redistributable Runtimes libraries and it solved my problem.
So I have my Notebook on Google Colab using Python 3 (and I will implement some Deep learning libraries ex: Keras, TF, Flair, OpenAI...) so I really want to keep using Python 3 and not switch to 2.
However, I have a .db file that I want to open/read, the script is written in Python 2 because they are using bsddb library (which is deprecated and doesn't work on Python 3)
self.term_to_id = bsddb.btopen(resource_prefix + '_term_to_id.db', 'r')
I tried modifying the Python 2 file to make it compatible on Python 3 so I can import it as a module in my Google Colab Notebook, what I tried:
I tried changing bsdbb to bsdbb3, and installing !pip install berkeleydb so I can do that later !pip install bsddb3 and just update bsdbb to bsdbb3 , but upon installing !pip install berkeleydbI get the following errors:
ERROR: Could not find a version that satisfies the requirement
berkeleydb (from versions: 18.1.0, 18.1.1, 18.1.2, 18.1.3, 18.1.4)
ERROR: No matching distribution found for berkeleydb
2)I thought maybe I could just import the dependency from python 2 file to my Python 3 notebook, but as expected it didn't work because it didn't recognize 'import bsdbb' in the Python 2 file.
Any tips/ work around to make it work on Google Colab ?
berkeleydb is only Python binding on database BerkeleyDB created in C/C++.
When I try to install it on my local system Linux Mint then I see error with
FileNotFoundError: [Errno 2] No such file or directory: 'src/Modules/berkeleydb.h'
which means that it tries to compile some C/C++ code.
And this usually need to install special package with C/C++ headers (files .h) with suffix -dev.
Using
!apt search Berkelay
I found that there is installed libdb5.3 so I installed libdb5.3-dev
!apt install libdb5.3-dev
and after that Python can install berkeleydb
This works for me on Colab
!apt install libdb5.3-dev
!pip install berkeleydb
import berkeleydb as bsddb
I am working on pose estimation using OpenPose. For that I installed TensorFlow GPU and installed all the requirements including CUDA development kit.
While running the Python script:
C:\Users\abhi\Anaconda3\lib\site-packages\tensorflow\python\ops\resource_variable_ops.py, I encountered the following error:
ImportError: cannot import name '_pywrap_utils' from
'tensorflow.python'
(C:\Users\abhi\Anaconda3\lib\site-packages\tensorflow\python__init__.py)
I tried searching for _pywrap_utils file but there was no such file.
Try pip3 install pywrap and pip3 install tensorflow pywrap utils should be included with tensorflow. If it is not found, that means TF was not installed correctly.
I try to learn TensorFlow with Python. My problem is with import TF module. Here is my configuration: Python 3.6.1, Windows 7 (with MSVCP140.dll)
I've installed TensorFlow by command (in power shell). It works.
python -m pip install --upgrade tensorflow
But when I run python environment and try import Tensor Flow
import tensorflow as tf
I get errors, this error raise another errors related with it, but at the beginning I want to resolve this first
Traceback (most recent call last): File
"C:\Users\Jacek\AppData\Local\Programs\Python\Python36\lib\site-packages\tensorflow\python\pywrap_tensorflow.py",
line 18, in swig_import_helper
fp, pathname, description = imp.find_module('_pywrap_tensorflow', [dirname(file)]) File
"C:\Users\Jacek\AppData\Local\Programs\Python\Python36\lib\imp.py",
line 296, in find_module
raise ImportError(_ERR_MSG.format(name), name=name) ImportError: No module named '_pywrap_tensorflow'
The problem was the cuDNN Library for me - for whatever reason cudnn-8.0-windows10-x64-v6.0 was NOT working - I used cudnn-8.0-windows10-x64-v5.1 - ALL GOOD!
My setup working with Win10 64 and the Nvidia GTX780M:
Be sure you have the lib MSVCP140.DLL by checking your system/path - if not get it here
Run the windows installer for python 3.5.3-amd64 from here - DO NOT try newer versions as they probably won't work
Get the cuDNN v5.1 for CUDA 8.0 from here - put it under your users folder or in another known location (you will need this in your path)
Get CUDA 8.0 x86_64 from here
Set PATH vars as expected to point at the cuDNN libs and python (the python path should be added during the python install)
If you run Windows 32 be sure to get the 32 bit versions of the files mentioned above.
Solution is downgrade Python to version 3.5, and install again TensorFlow. It works for me
This is a known error. There is a file named MSVCP140.DLL, that you will need in your system to run TensorFlow. Check if this file is in your %path%. If it is not, download Visual Studio C++. It is free and you can download it here: https://www.visualstudio.com/vs/cplusplus.
Solution:-
Don't suffer a lot. Simply downgrade your python version from 3.6.1 to 3.5.2 and
install tensorflow again.. you need not to upgrade the package.
"pip install tensorflow" will automatically download latest version (probably
1.0.1)
Steps:-
Step 1:- conda search python
Step 2:- conda install python=3.5.2
Step 3:- pip install tensorflow
Step 4:- import tensorflow as tf
Horray!!.. It works..
Hope you may not get the same error again!!
At first, I used an anaconda environment with Python 3.5 and PIP version 19 but had the same problem. so instead of PIP, I used Conda package manager:
conda install TensorFlow
it worked well after using Conda instead of PIP
If you have a GPU in your system and it is conflicting with the current set of libraries or throwing a cudnn error then you can add the following line in your code to disable the GPU
os.environ["CUDA_VISIBLE_DEVICES"] = "-1"
put this in your code and it should be fine.
pip install tensorflow-gpu
Install this package this helps me to solve my issues
or else use python 3.9.7
Error msg (check the screenshot picture please):
ImportError: cannot import name symbol_database
Error importing tensorflow. Unless you are using bazel,
you should not try to import tensorflow from its source directory;
please exit the tensorflow source tree, and relaunch your python interpreter
from there.
Process finished with exit code 1
Thanks a lot !
I tried to reproduce the problem you're running into using this sample code:
import tensorflow as tf
hello = tf.constant('Hello, Tensorflow!')
But I was not able to. I can run the script without issues within PyCharm and in my command line (exit code 0).
These are the packages (and their version) that are required for tensorflow 0.8.0 to work:
numpy==1.11.0
protobuf==3.0.0b2
six==1.10.0
I'm using PyCharm Community Edition 2016.1.2 and Python 2.7.10 on Mac OS X 10.11.4
How did you install tensorflow?
You should install it via pip (as recommended by the site: https://www.tensorflow.org/versions/r0.8/get_started/os_setup.html#pip-installation)
For Python 2, Mac OS X, this is the installation command:
pip install --upgrade https://storage.googleapis.com/tensorflow/mac/tensorflow-0.8.0-py2-none-any.whl