AttributeError: 'module' object has no attribute 'DEVNULL' - python-2.7

from nltk.parse.corenlp import CoreNLPServer
server = CoreNLPServer()
server.start()
When I run the above code, I'm getting the following error.
Traceback (most recent call last):
File "server.py", line 30, in <module>
server.start()
File "/usr/local/lib/python2.7/dist-packages/nltk/parse/corenlp.py", line 130, in start
stderr=stderr,
File "/usr/local/lib/python2.7/dist-packages/nltk/internals.py", line 112, in java
subprocess_output_dict = {'pipe': subprocess.PIPE, 'stdout': subprocess.STDOUT, 'devnull': subprocess.DEVNULL}
AttributeError: 'module' object has no attribute 'DEVNULL'

subprocess.devnull is new in Python 3.3.
Make sure you use a version of nltk which stil supports Python 2.7. From their changelog:
Version 3.5 2019-10-16
* drop support for Python 2

Related

Attribute Error: 'module' object has no attribute 'GraphKeys'

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

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 can't run ANY script

I have Python 2.7.14 64-bit version installed and I can't run the simplest of scripts. It works normal if I copy to Shell and run from there. This is the script I'm trying to run.
def fun(a):
print a
return
And the error message
Exception in Tkinter callback
Traceback (most recent call last):
File "C:\Python27\lib\lib-tk\Tkinter.py", line 1541, in __call__
return self.func(*args)
File "C:\Python27\lib\idlelib\MultiCall.py", line 166, in handler
r = l[i](event)
File "C:\Python27\lib\idlelib\ScriptBinding.py", line 149, in run_module_event
if PyShell.use_subprocess:
AttributeError: 'module' object has no attribute 'use_subprocess'

Pyforms, pysettings and pyinstaller, object has no attribute 'settings'

I have problem with pyforms and pysettings in python 2.7 after compilation to the executable file.
Script runs normally and without errors when executed by "python godziny.py".
However after I create executable file (currently I use pyinstaller, but I also tried py2exe and cx_freeze with the same problem) I start the app and receive following:
C:\...>dist\godziny\godziny.exe
Traceback (most recent call last):
File "godziny.py", line 10, in <module>
from pyforms import BaseWidget
File "c:\users\...\appdata\local\temp\pip-build-hzzm3w\pyinstaller\PyInstaller\loader\pyimod03_importers.py", line 389, in load_module
File "site-packages\pyforms\__init__.py", line 6, in <module>
File "site-packages\pysettings\settings_manager.py", line 22, in __add__
File "site-packages\pysettings\settings_manager.py", line 16, in __load_module
AttributeError: 'module' object has no attribute 'settings'
Failed to execute script godziny
I'm using Python 2.7, with pysettings from Pysettings and pyforms from pip (0.1.7.3). Pyinstaller doesn't report any errors during compilation.

subprocess AttributeError: 'module' object has no attribute 'check_ouput' aix

Not sure why im getting this error as subprocess check_output is in python 2.7 which im running?
ctmtest1-tctmsv80 [10] python del_jobs_main.py
sys.version_info(major=2, minor=7, micro=5, releaselevel='final', serial=0)
Traceback (most recent call last):
File "del_jobs_main.py", line 51, in <module>
sys.exit(main())
File "del_jobs_main.py", line 42, in main
p_call = do_sh_shell_command('env | grep machine')
File "del_jobs_main.py", line 33, in do_sh_shell_command
p = subprocess.check_ouput(string_command, shell=True, stdin=subprocess.PIPE,
AttributeError: 'module' object has no attribute 'check_ouput'
any help on this weird error would be greatly appreciated