NameError: name 'python' is not defined when importing part of tensorflow's deeplab module - tensorflow

Thanks to this github issue, I realise that I shouldn't try to reload tensorflow, because I get this error:
del python
NameError: name 'python' is not defined
when I do
import tensorflow
from deeplab import common
In case it's relevant, import deeplab works fine.
I saw elsewhere that it's probably the IPython session in spyder that is keeping a tensorflow session open. So I closed spyder - but launching python in the shell gave me the same issue. ps -ef | grep -E 'py|tensorflow|tensorboard|tf' came up empty. What could still be hanging around and causing tensorflow to try a reload, rather than a fresh load?
I understand that the issue around reloading tensorflow will not be resolved. How do I make sure that I have cleared everything from my previous runs so that it will be a fresh load rather than a reload?
Edit: even after restarting the computer I get the same error. Even if the first thing I do is open a python console and type from deeplab import common. That means the original title to my question is probably wrong, so I have changed it.

Related

TensorCirucit c.draw() NameError

I want to plot a circuit build with TensorCircuit using the draw method.
I am working on Google Colab and have pip installed qiskit.
Yet i get NameError: name 'QuantumCircuit' is not defined.
I have also tried from qiskit import QuantumCircuit but still i get the same error.
Executing the code on another JuypterHub works.
pip install qiskit
pip install pylatexenc
import numpy as np
from qiskit import *
Once you are done with above code you have to restart your runtime so that installed library come into force into your colab environment.
For restarting runtime:
Click on Runtime
Select Restart runtime
Select Run all
This help you to rectify your problem.

Gradient Boosting classifier issue

I am getting crazy trying to fix the issue of "name 'XGBClassifier' is not defined".
Any clue please?
My environment is Win 64, Python 3.7
This can be very open ended issue. I would suggest you to check if Xgboost is imported or not , if not imported than is there any installation issue or not-
try:
import xgboost
except ImportError:
pass
except:
print("xgboost is installed...but failed to load!")
pass
Other points to be consider,
Try to work in virtual environment which can exempt the other packages conflict with xgboost version.
Check the Input shape - there are times when this is the root cause of issue.

Send help in the form of someone who knows python well

I am currently well versed in java, but I am trying to get into python. I know the basics, but am struggling with package use and implementation into source code.
I have successfully installed both numpy and Pillow (or PIL):
Click here for cmd telling me both packages have been installed
When I typed import numpy into cmd running python, it worked no problem, but now I've tried to open IDLE and import it there, and written source code trying to import it and utalise parts of the numpy lib but it always gives me a ModuleNotFoundError
python idle shell import vs. cmd import
My folder layout is a little wacky:
C:
..Users
....B
......ForImagingProject
........PYTHON
..........(python standard subfolders)
..........Lib
............site-packages
..............numpy and PIL and pip here
Any and all help would be appreciated
Thanks ~ B
EDIT: I messed up and my IDLE shortcut was running idle.pyw instead of idle.bat. Everything working smoothly now.
Check your IDLE's python executable. Is it the same one as in your cmd prompt?
The easiest way to check is to run this:
import sys
print(sys.path)
Look for something like
'PATH_TO_PYTHON/python/3.7.0/Frameworks/Python.framework/Versions/3.7/lib/python3.7'or
'PATH_TO_PYTHON/Frameworks/Python.framework/Versions/2.7/lib/python2.7'
Make sure this is the same in both the IDLE and in cmd.
The reason the shell I was working in was unable to recognize the module was because my IDLE shortcut was mapped to idle.pyw instead of idle.bat. Everything running smoothly now

OpenAI Gym error running demo from intro page

I installed OpenAI Gym and attempted to run the getting-started cart-pole demo (https://gym.openai.com/docs/). (I'm running in a Colab notebook.)
import gym
env = gym.make('CartPole-v0')
env.reset()
for _ in range(1000):
env.render()
env.step(env.action_space.sample()) # take a random action
This doesn't learn, but it should display the cart and pole.
When I run it I get a warning and an error.
WARN: gym.spaces.Box autodetected dtype as <class 'numpy.float32'>. Please provide explicit dtype.
The error is triggered by env.render(). At the bottom of the Traceback is
Error occured while running `from pyglet.gl import *`
The original exception was:
ImportError: Library "GL" not found.
I had installed pyOpenGL with the following.
!pip install PyOpenGL PyOpenGL_accelerate
I'd appreciate help with both the warning and the error. Is there another GL library I should install?
Thanks.
Google Colab is run in the cloud. It can't send the graphic display back to your monitor.
You can try running it with local runtime.
https://research.google.com/colaboratory/local-runtimes.html
Do you get this window?
If yes then try to add this import:
import time
and this line of Code within the for-loop:
time.sleep(0.3)
Thing is that the pole runs out of view rather quick, so it seems like
the Environment did not run at all.

ImportError: cannot import name 'preprocessor_pb2' in the training part after installation was successful

I installed the object detection API correctly using this https://github.com/tensorflow/models/blob/master/research/object_detection/g3doc/installation.md and I checked by running model_builder_test.py
This gave me a OK result.
Then I moved on to running the train.py on my dataset using the following command
python train.py --logtostderr --pipeline_config_path=pipeline.config --train_dir=train_file
And I am getting the error ImportError: cannot import name 'preprocessor_pb2'
This particular preprocessor_pb2.py exists in the path it is looking for i.e
C:\Users\SP-TestMc\Anaconda3\envs\tensorflow\models-master\models-master\research\object_detection\protos
What could be the reason for this error then?
See https://github.com/tensorflow/models/blob/master/research/object_detection/g3doc/installation.md#protobuf-compilation. Sounds like you need to compile the protos before using the Python scripts.