How to install tensorflow without pip in the right way? - python

So I have installed tensorflow with pip using pip install tensorflow==1.15 a few days ago, today I wanted to search for my models-master file and I didn't find it. I uninstalled tensorflow using pip uninstall tensorflow and then I installed it from the github and added it to the folder of the project I am working on like, it is in the same folder as the .py files of my original project. This is because I need to use protoc on the files because I got error messages before. I think I got the protoc part down now but I can't test it, because whenever I want to run my main file, I get this error message:
Traceback (most recent call last):
File "C:\Users\user\Desktop\captcha solver\main_.py", line 1, in <module>
from CAPTCHA_object_detection import *
File "C:\Users\user\Desktop\captcha solver\CAPTCHA_object_detection.py", line 18, in <module>
from object_detection.utils import ops as utils_ops
File "C:\Users\user\AppData\Local\Programs\Python\Python36\lib\site-packages\object_detection\utils\ops.py", line 291, in <module>
dtype=tf.float32):
AttributeError: module 'tensorflow' has no attribute 'float32'
I think this is because of the way I installed tensorflow, but I don't know what I did wrong, I have never installed modules without pip though.

Related

How do I get my scikit-learn library to work on windows using pip package installer?

I am using the windows command prompt to install the scikit learn library using the command pip install -U scikit-learn. However, whenever I try to import it into my program I get an error stating that there is no module named 'sklearn'. Also, whenever I download the library using pip, for some reason, my pip package installer seems to break and pip is no longer recognized as a command on my cmd. I have numerous other modules which work perfectly fine so I don't see a reason as to why I can't get this specific library to work. I am still quite new to this kind of thing, so maybe I am missing something.
Traceback (most recent call last):
File "<pyshell#0>", line 1, in
import sklearn
File "C:\Users\Ryan\AppData\Local\Programs\Python\Python39\lib\site-packages\sklearn_init_.py", line 82, in
from .base import clone
File "C:\Users\Ryan\AppData\Local\Programs\Python\Python39\lib\site-packages\sklearn\base.py", line 17, in
from .utils import IS_32BIT
File "C:\Users\Ryan\AppData\Local\Programs\Python\Python39\lib\site-packages\sklearn\utils_init.py", line 20, in
from scipy.sparse import issparse
File "C:\Users\Ryan\AppData\Local\Programs\Python\Python39\lib\site-packages\scipy\sparse_init_.py", line 227, in
from .base import *
File "C:\Users\Ryan\AppData\Local\Programs\Python\Python39\lib\site-packages\scipy\sparse\base.py", line 4, in
from .sputils import (isdense, isscalarlike, isintlike,
File "C:\Users\Ryan\AppData\Local\Programs\Python\Python39\lib\site-packages\scipy\sparse\sputils.py", line 8, in
from scipy._lib._util import prod
ModuleNotFoundError: No module named 'scipy._lib._util'
Try to upgrade pip to newest version by python -m pip install --upgrade pip considering you are still using Windows. And then try to download sciKitLearn by pip install sklearn
This is how I had solved my problem but keep note that it was about a year ago
If all this doesn't work, try VirtualEnv.

Tensorflow: Object detection api error on google colab-no module named lvis

I'm trying to run 'model_main_tf2.py' in Tensorflow object detection on google colab.
Paths are alredy defined
os.environ['PYTHONPATH']+=":/content/gdrive/My Drive/TensorFlow_2/models"
os.environ['PYTHONPATH']+=":/content/gdrive/My Drive/TensorFlow_2/models/research"
os.environ['PYTHONPATH']+=":/content/gdrive/My Drive/TensorFlow_2/models/research/slim"
But i have an error
File "/usr/local/lib/python3.6/dist-packages/object_detection-0.1-py3.6.egg/object_detection/metrics/lvis_evaluation.py", line 23, in <module>
from lvis import results as lvis_results
ModuleNotFoundError: No module named 'lvis'
It looks like your program is trying to import results from the package lvis
Make sure you have it installed, if you don't run
pip install lvis
in the command line
if you did install it and you still get this error i might be becuase it is not installed in the same python as the one you are trying to run your program with.
So in the command line type
pip list
to make sure you have lvis installed and then run you .py file (i think it's lvis_evaluation.py) from the command line and see if it works.

module 'tensorflow' has no attribute 'contrib' while

About OC: Ubuntu 16.04 LTS x86_64; GRX CUDA 10.2; cudnn ... etc.
TF: 2.1.0; Python 3.6
About the problem:
When I launch module_main.py an error is displayed. When I launch it /legacy/train.py similarly, an error appears.
Is it possible to fix this problem without downgrading the tensorflow version and without reinstalling the drivers?
Is changing the code via a script the only way?
Logs below:
model_main.py
Traceback (most resent call last):
File "models/research/object_detection/model_main.py",
line 26, in <module> from object_detection import model_lib
File "/root/ObjectDetection/models/research/object_detection/model_lib.py"
line 27, in <module> from object_detection import eval_lib
File "/root/ObjectDetection/models/research/object_detection/eval_util.py",
line 40, in <module> slim = tf.contrib.slim
AttributeError: module 'tensorflow' has no attribute 'contrib'
Also using conda env
thx, for some advice
I faced the same issue. Tensorflow 2.0 has removed tf.contrib. I tried to fixed the error by changing the code. And it lead to many other error.
I fixed this issue by downgrading tensorflow to 1.14.0
Run these commands on terminal:
pip uninstall tensorflow
pip install tensorflow==1.14.0

AttributeError: module 'tensorboard.util' has no attribute 'PersistentOpEvaluator' , when trying to use TensorBoard

I made some log files using tensorboard but I can't access them.
Using
tensorboard or tensorboard --logdir=logs/ on the command prompt
gives the following error:-
C:\Users\User>tensorboard
Traceback (most recent call last):
File "C:\Users\User\Anaconda3\Scripts\tensorboard-script.py", line 6, in <module>
from tensorboard.main import run_main
File "C:\Users\User\Anaconda3\lib\site-packages\tensorboard\main.py", line 40, in <module>
from tensorboard import default
File "C:\Users\User\Anaconda3\lib\site-packages\tensorboard\default.py", line 38, in <module>
from tensorboard.plugins.beholder import beholder_plugin
File "C:\Users\User\Anaconda3\lib\site-packages\tensorboard\plugins\beholder\__init__.py", line 15, in <module>
from tensorboard.plugins.beholder.beholder import Beholder
File "C:\Users\User\Anaconda3\lib\site-packages\tensorboard\plugins\beholder\beholder.py", line 25, in <module>
from tensorboard.plugins.beholder import im_util
File "C:\Users\User\Anaconda3\lib\site-packages\tensorboard\plugins\beholder\im_util.py", line 89, in <module>
class PNGDecoder(util.PersistentOpEvaluator):
AttributeError: module 'tensorboard.util' has no attribute 'PersistentOpEvaluator'
I tried this solution, but it did not help.
I also had a big fight with this problem. What eventually worked for me was the following:
pip uninstall tensorflow
pip uninstall tensorboard
conda show OR pip show --> have a look at which other tensorflow related packages you have installed and remove them.
Go to site-packages and remove tensorflow/tensorboard folders (look for any folder in your filesystem related to a tensorflow / tensorboard installation)
conda clean --all (not sure if this is necessary, but it was one of
my steps and might be relevant)
Reinstall tensorflow and tensorboard. Preferably use conda as it is faster by several orders of magnitude
One of my main sources in solving this issue was this github issue thread:
https://github.com/tensorflow/tensorboard/issues/1724
Try to install these packages with Conda Run:
conda install -c anaconda tensorflow-gpu
conda install -c anaconda keras

Install python caffe with anaconda2 (pycaffe)

I'm trying to to be able to run this demo https://github.com/ZheC/Realtime_Multi-Person_Pose_Estimation
I'm running ubuntu 14.04
I have installed Anaconda, and after installing many many many dependencies another one pops. It also requires python caffe
So I installed it with this command:
(I also tried Pip install caffe but if failed)
Conda install caffe
But then when I try to run it I get:
$python
>>> import caffe
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/home/gtkratosman-lap/anaconda2/lib/python2.7/site-packages/caffe/__init__.py", line 1, in <module>
from .pycaffe import Net, SGDSolver, NesterovSolver, AdaGradSolver, RMSPropSolver, AdaDeltaSolver, AdamSolver, NCCL, Timer
File "/home/gtkratosman-lap/anaconda2/lib/python2.7/site-packages/caffe/pycaffe.py", line 13, in <module>
from ._caffe import Net, SGDSolver, NesterovSolver, AdaGradSolver, \
ImportError: libprotobuf.so.12: cannot open shared object file: No such file or directory
I have been able to verify this behaviour in my own Anaconda environment running conda v4.3.27 in a Python v2.7.14 virtual environment, installing caffe v1.0.0rc5.
Having looked further into the issue, it seems it relates to the following open Anaconda issue: caffe needs to pin protobuf requirement to version #6733
As described in the issue:
The caffe and caffe-gpu package in defaults has a requirement on protobuf without any version dependencies. Unfortunately, the caffe packages links to libprotobuf.so.12 which is provided by the protbuf version 3.2.0
As such, I found I was able to successfully import caffe in Python, running in my Anaconda virtual environment, by first manually installing protobuf v3.2.0, as follows: conda install protobuf==3.2.0

Categories