Attribute Error: 'module' object has no attribute 'GraphKeys' - python-2.7

I'm currently trying to get a chatbot running with tensorflow.
The example for the chatbot is from this repository:
Github
I ran into some issues when I tried to run this in my tensorflow docker container.
When starting the script the script exits with an Attribute Error.
Traceback (most recent call last):
File "chatbot.py", line 5, in <module>
import tensorlayer as tl
File "/usr/local/lib/python2.7/dist-packages/tensorlayer/__init__.py", line 47, in <module>
from tensorlayer import initializers
File "/usr/local/lib/python2.7/dist-packages/tensorlayer/initializers.py", line 7, in <module>
from tensorlayer.layers.core import LayersConfig
File "/usr/local/lib/python2.7/dist-packages/tensorlayer/layers/__init__.py", line 12, in <module>
from .activation import *
File "/usr/local/lib/python2.7/dist-packages/tensorlayer/layers/activation.py", line 6, in <module>
from tensorlayer.layers.core import Layer
File "/usr/local/lib/python2.7/dist-packages/tensorlayer/layers/core.py", line 39, in <module>
TF_GRAPHKEYS_VARIABLES = tf.GraphKeys.GLOBAL_VARIABLES
AttributeError: 'module' object has no attribute 'GraphKeys'
I'm using the following Versions:
tensorflow 2.0.0a0
tensorlayer 1.11.1
Maybe some of you had already a similar issue and knows how I could solve this problem.

I solved this problem using pip install tensorflow==1.13.2

Maybe tl mismatch tf, you need to update your tensorlayer to 2.0+.you can use this instruction:
pip3 install https://github.com/tensorlayer/tensorlayer/archive/master.zip

Related

Getting "No module named queue" when installing tensorflow

I am using Anaconda and trying to install tensorflow with pip, but I receive the following error and I am not sure what to do next?
Traceback (most recent call last):
File "/home/xieyangyang/anaconda3/envs/tensorflow1/bin/pip", line 7, in <module>
from pip._internal import main
File "/home/xieyangyang/anaconda3/envs/tensorflow1/lib/python2.7/site-packages/pip/_internal/__init__.py", line 20, in <module>
from pip._vendor.urllib3.exceptions import DependencyWarning
File "/home/xieyangyang/anaconda3/envs/tensorflow1/lib/python2.7/site-packages/pip/_vendor/urllib3/__init__.py", line 8, in <module>
from .connectionpool import (
File "/home/xieyangyang/anaconda3/envs/tensorflow1/lib/python2.7/site-packages/pip/_vendor/urllib3/connectionpool.py", line 44, in <module>
from .util.queue import LifoQueue
ImportError: No module named queue
Maybe just reinstall pip without pip?
curl https://bootstrap.pypa.io/get-pip.py -o get-pip.py
python get-pip.py
See https://pip.pypa.io/en/stable/installing/ for more info.

Error in gcloud " AttributeError: 'module' object has no attribute 'DEFAULT_MAX_REDIRECTS'"

I am trying to implement firebase functions cron job from this link : https://github.com/firebase/functions-cron
Everything worked properly
But when I try to run google cloud cron job it gives me below error :
(/base/alloc/tmpfs/dynamic_runtimes/python27/c5586dbb532f7e5f_unzipped/python27_lib/versions/1/google/appengine/runtime/wsgi.py:263)
Traceback (most recent call last):
File "/base/alloc/tmpfs/dynamic_runtimes/python27/c5586dbb532f7e5f_unzipped/python27_lib/versions/1/google/appengine/runtime/wsgi.py", line 240, in Handle
handler = _config_handle.add_wsgi_middleware(self._LoadHandler())
File "/base/alloc/tmpfs/dynamic_runtimes/python27/c5586dbb532f7e5f_unzipped/python27_lib/versions/1/google/appengine/runtime/wsgi.py", line 299, in _LoadHandler
handler, path, err = LoadObject(self._handler)
File "/base/alloc/tmpfs/dynamic_runtimes/python27/c5586dbb532f7e5f_unzipped/python27_lib/versions/1/google/appengine/runtime/wsgi.py", line 85, in LoadObject
obj = __import__(path[0])
File "/base/data/home/apps/s~debitcredit-7ecc0/20180506t121449.409523654918066893/main.py", line 18, in <module>
import pubsub_utils
File "/base/data/home/apps/s~debitcredit-7ecc0/20180506t121449.409523654918066893/pubsub_utils.py", line 24, in <module>
import oauth2client.contrib.appengine as gae_oauth2client
File "./lib/oauth2client/contrib/appengine.py", line 36, in <module>
from oauth2client import client
File "./lib/oauth2client/client.py", line 39, in <module>
from oauth2client import transport
File "./lib/oauth2client/transport.py", line 255, in <module>
redirections=httplib2.DEFAULT_MAX_REDIRECTS,
AttributeError: 'module' object has no attribute 'DEFAULT_MAX_REDIRECTS'
I tried this solution : Getting AttributeError: 'module' object has no attribute 'DEFAULT_MAX_REDIRECTS' when running Google Sheets API quickstart
But still no luck.
Can anyone please help me with this.
Issue is with your httplib Module.
When you installed this module for your project you must have installed it with pip for Python 3
If you want to check whether this module is for python 3 or python 2,
Go to httplib2 module and go inside its init.py
later see this line Requires Python 3 or later
if it is written like that means you have installed this library with pip for python 3. Now delete all the httplib2 from your lib folder.
Create a seperate enviroment for python 2.7 and again install all your modules with pip install -t lib -r requirements.txt

python PyUserInput import error

Hi I am trying to download PyUserInput, I downloaded it using pip and there were no errors. When I try to import it into a file in give me an error which I do not understand. I have a basic understanding of python and pip.Any help will be much appreciated.I have pasted the error I get below.
Traceback (most recent call last):
File "<pyshell#0>", line 1, in <module>
from pymouse import PyMouse
File "/usr/local/lib/python2.7/dist-packages/pymouse/__init__.py", line 41, in <module>
from .x11 import PyMouse, PyMouseEvent
File "/usr/local/lib/python2.7/dist-packages/pymouse/x11.py", line 16, in <module>
from Xlib.display import Display
File "/usr/local/lib/python2.7/dist-packages/Xlib/display.py", line 26, in <module>
from six import create_unbound_method
ImportError: cannot import name create_unbound_method
Thanks
I had the same problem on old raspberry pi image and upgrading six solved the issue for me:
sudo pip install six --upgrade

python ImportError: No module named cy_unity graphlab

I am new to python and I am trying to work on a project with deep learning and want to use graphlab library. I use sublime text for coding on windows 10. My code is only this line:
import graphlab
I get this error msg:
Traceback (most recent call last):
File "test.py", line 1, in
import graphlab
File "graphlab__init__.py", line 59, in
from graphlab.data_structures.sgraph import Vertex, Edge
File "graphlab\data_structures__init__.py", line 25, in
from . import sframe
File "graphlab\data_structures\sframe.py", line 19, in
from ..connect import main as glconnect
File "graphlab\connect\main.py", line 26, in
from ..cython.cy_unity import UnityGlobalProxy
ImportError: No module named cy_unity
Try using graphlab.get_dependencies() in your interpreter.
I think I made a mistake when installing, i re-installed and it worked fine. Thanks anyway

Import and Environment Variable issues using Python/Django in PYcharm on Ubuntu

I am working through the PYcharm tutorial, which sets up a polling site, as my first Python/Django project. I am new to this so if I am asking silly questions I apologize in advance. In the admin.py file the following import is not working:
from MyDjangoApp.polls.models import Poll, Choice
I have specified the environment variable as I found in other posts to
DJANGO_SETTINGS_MODULE MyDjangoApp.settings
with MyDjangoApp being my project name and MyDjangoApp.settings as the value in the Edit Configurations tab.
I also tried to follow the lightbulb suggestion to install package models but when I do that I get the following error:
Error occurred when installing packages.
The following command was executed:
packaging_tool.py install --build-dir /tmp/pycharm packaging1986982253689628475.tmp
models
The error output of the command:
Downloading/unpacking models
Downloading models-0.9.3.tar.gz
Running setup.py egg_info for package models
Traceback (most recent call last):
File "<string>", line 14, in <module>
File "/tmp/pycharm-packaging1986982253689628475.tmp/models/setup.py", line 25, in
<module>
import models
File "models/__init__.py", line 24, in <module>
from props import *
File "models/props.py", line 23, in <module>
import yaml
ImportError: No module named yaml
Complete output from command python setup.py egg_info:
Traceback (most recent call last):
File "<string>", line 14, in <module>
File "/tmp/pycharm-packaging1986982253689628475.tmp/models/setup.py", line 25, in
<module>
import models
File "models/__init__.py", line 24, in <module>
from props import *
File "models/props.py", line 23, in <module>
import yaml
ImportError: No module named yaml
----------------------------------------
Command python setup.py egg_info failed with error code 1 in /tmp/pycharm
-packaging1986982253689628475.tmp/models
Storing complete log in /home/andrew/.pip/pip.log
I am not sure how to proceed. I have seen a decent amount of suggestions but they either don't work or I'm not doing it correctly. If anyone has any suggestions I would greatly appreciate it. I have been banging my head against this wall most of the day today and I would really like to be able to move forward. Thanks is advance for anyone willing to help out a newbie.
In polls/admin.py do from models import Poll, Choice - this is presuming you have a models.py file next to admin.py.