torchtext - content-disposition Error - download_from_url - torch

I am trying to download the dataset using torchtext and getting the following error
from torchtext.utils import download_from_url, extract_archive
from torchtext.datasets.text_classification import URLS
download_from_url(URLS["AG_NEWS"])
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/home/ubuntu/anaconda3/lib/python3.8/site-packages/torchtext/utils.py", line 122, in download_from_url
return _process_response(response, root, filename)
File "/home/ubuntu/anaconda3/lib/python3.8/site-packages/torchtext/utils.py", line 66, in _process_response
d = r.headers['content-disposition']
File "/home/ubuntu/anaconda3/lib/python3.8/site-packages/requests/structures.py", line 54, in __getitem__
return self._store[key.lower()][1]
KeyError: 'content-disposition'
I am using torchtext 0.7.0 and the same error is getting replicated in the latest version as well. Can someone help ?

Related

Attribute error while creating web page with justpy

Hi I was creating a simple plain web page with justpy and I got an attribute error.
This was the code:
import justpy as jp
def app():
wp = jp.WebPage()
return wp
jp.justpy(app)
this was the error:
/usr/local/lib/python3.6/dist-packages/justpy
Module directory: /usr/local/lib/python3.6/dist-packages/justpy, Application directory: /home/nsu/Desktop/datavisual
Traceback (most recent call last):
File "Web_App_1.py", line 7, in <module>
jp.justpy(app)
File "/usr/local/lib/python3.6/dist-packages/justpy/justpy.py", line 383, in justpy
uvicorn.run(app, host=host, port=port, log_level=UVICORN_LOGGING_LEVEL)
File "/usr/local/lib/python3.6/dist-packages/uvicorn/main.py", line 461, in run
server.run()
File "/usr/local/lib/python3.6/dist-packages/uvicorn/server.py", line 67, in run
return asyncio.run(self.serve(sockets=sockets))
AttributeError: module 'asyncio' has no attribute 'run'
I tried to replace jp.WebPage() with jp.QuasarPage() but got the same error
pls help.

Is pyautogui work in the ubuntu 18.04 server version with no display accessed via ssh?

When I am import pyautogui it gives me:
Traceback (most recent call last):
File "app.py", line 2, in <module>
from register import reg
File "/home/nlp/Projects/face_recognition/register.py", line 12, in <module>
import pyautogui
File "/home/nlp/miniconda3/envs/face_recognition_env/lib/python3.6/site-packages/pyautogui/__init__.py", line 241, in <module>
import mouseinfo
File "/home/nlp/miniconda3/envs/face_recognition_env/lib/python3.6/site-packages/mouseinfo/__init__.py", line 223, in <module>
_display = Display(os.environ['DISPLAY'])
File "/home/nlp/miniconda3/envs/face_recognition_env/lib/python3.6/site-packages/Xlib/display.py", line 80, in __init__
self.display = _BaseDisplay(display)
File "/home/nlp/miniconda3/envs/face_recognition_env/lib/python3.6/site-packages/Xlib/display.py", line 62, in __init__
display.Display.__init__(*(self, ) + args, **keys)
File "/home/nlp/miniconda3/envs/face_recognition_env/lib/python3.6/site-packages/Xlib/protocol/display.py", line 58, in __init__
self.socket = connect.get_socket(name, host, displayno)
File "/home/nlp/miniconda3/envs/face_recognition_env/lib/python3.6/site-packages/Xlib/support/connect.py", line 76, in get_socket
return mod.get_socket(dname, host, dno)
File "/home/nlp/miniconda3/envs/face_recognition_env/lib/python3.6/site-packages/Xlib/support/unix_connect.py", line 78, in get_socket
raise error.DisplayConnectionError(dname, str(val))
Xlib.error.DisplayConnectionError: Can't connect to display ":0": [Errno 2] No such file or directory
I have tried this:
import os
os.environ['DISPLAY'] = ':0'
But still same error. According to one comment of to this link (https://github.com/asweigart/pyautogui/issues/161) in github says it is not accessible remotely. I have tried sudo xhost + command but it gives me below error.
xhost: unable to open display ""

AuthorizationFailed - "The client 'xxx' with object id 'xxx does not have authorization to perform action

I've tried to get Workspace from config which I do have access to, but it fails with the following error:
import azureml.core
print("SDK version:", azureml.core.VERSION)
from azureml.core.workspace import Workspace
ws = Workspace.from_config()
print(ws.name, ws.resource_group, ws.location, ws.subscription_id, sep='\n')
SDK version: 0.1.80 Found the config file in:
C:\Users\gubert\Repos\Gimmonix\HotelMappingAI\aml_config\config.json
get_workspace error using subscription_id=xxxxxxxxxxxxxxxxxxxxxxx,
resource_group_name=xxxxxxxxxxxx, workspace_name=gmx-ml-mapping
Traceback (most recent call last): File
"C:\Users\gubert.azureml\envs\myenv\lib\site-packages\azureml_project_commands.py",
line 320, in get_workspace workspace_name) File
"C:\Users\gubert.azureml\envs\myenv\lib\site-packages\azureml_base_sdk_common\workspace\operations\workspaces_operations.py",
line 78, in get raise
models.ErrorResponseWrapperException(self._deserialize, response)
azureml._base_sdk_common.workspace.models.error_response_wrapper.ErrorResponseWrapperException:
Operation returned an invalid status code 'Forbidden'
During handling of the above exception, another exception occurred:
Traceback (most recent call last): File
"c:\Users\gubert.vscode\extensions\ms-python.python-2018.10.1\pythonFiles\experimental\ptvsd_launcher.py",
line 38, in main(sys.argv) File
"c:\Users\gubert.vscode\extensions\ms-python.python-2018.10.1\pythonFiles\experimental\ptvsd\ptvsd_main_.py",
line 265, in main wait=args.wait) File
"c:\Users\gubert.vscode\extensions\ms-python.python-2018.10.1\pythonFiles\experimental\ptvsd\ptvsd_main_.py",
line 256, in handle_args run_main(addr, name, kind, *extra, **kwargs)
File
"c:\Users\gubert.vscode\extensions\ms-python.python-2018.10.1\pythonFiles\experimental\ptvsd\ptvsd_local.py",
line 52, in run_main runner(addr, name, kind == 'module', *extra,
**kwargs) File "c:\Users\gubert.vscode\extensions\ms-python.python-2018.10.1\pythonFiles\experimental\ptvsd\ptvsd\runner.py",
line 32, in run set_trace=False) File
"c:\Users\gubert.vscode\extensions\ms-python.python-2018.10.1\pythonFiles\experimental\ptvsd\ptvsd_vendored\pydevd\pydevd.py",
line 1283, in run return self._exec(is_module, entry_point_fn,
module_name, file, globals, locals) File
"c:\Users\gubert.vscode\extensions\ms-python.python-2018.10.1\pythonFiles\experimental\ptvsd\ptvsd_vendored\pydevd\pydevd.py",
line 1290, in _exec pydev_imports.execfile(file, globals, locals) #
execute the script File
"c:\Users\gubert.vscode\extensions\ms-python.python-2018.10.1\pythonFiles\experimental\ptvsd\ptvsd_vendored\pydevd_pydev_imps_pydev_execfile.py",
line 25, in execfile exec(compile(contents+"\n", file, 'exec'), glob,
loc) File "c:\Users\gubert\Repos\Gimmonix\HotelMappingAI\test.py",
line 8, in ws = Workspace.from_config() File
"C:\Users\gubert.azureml\envs\myenv\lib\site-packages\azureml\core\workspace.py",
line 153, in from_config auth=auth) File
"C:\Users\gubert.azureml\envs\myenv\lib\site-packages\azureml\core\workspace.py",
line 86, in init auto_rest_workspace = _commands.get_workspace(auth,
subscription_id, resource_group, workspace_name) File
"C:\Users\gubert.azureml\envs\myenv\lib\site-packages\azureml_project_commands.py",
line 326, in get_workspace resource_error_handling(response_exception,
WORKSPACE) File
"C:\Users\gubert.azureml\envs\myenv\lib\site-packages\azureml_base_sdk_common\common.py",
line 270, in resource_error_handling raise
ProjectSystemException(response_message)
azureml.exceptions._azureml_exception.ProjectSystemException: {
"error_details": { "error": { "code": "AuthorizationFailed",
"message": "The client 'xxxxxxxxxx#microsoft.com' with object id
'xxxxxxxxxxxxx' does not have authorization to perform action
'Microsoft.MachineLearningServices/workspaces/read' over scope
'/subscriptions/xxxxxxxxxxxxxx/resourceGroups/CarsolizeCloud - Test
Global/providers/Microsoft.MachineLearningServices/workspaces/gmx-ml-mapping'."
} }, "status_code": 403, "url":
"https://management.azure.com/subscriptions/xxxxxxxxxxxxx/resourceGroups/CarsolizeCloud%20-%20Test%20Global/providers/Microsoft.MachineLearningServices/workspaces/gmx-ml-mapping?api-version=2018-03-01-preview"
}
Try using the newest SDK version 1.0.10, this is a fairly old preview version you're using. If you still have a problem, let me know as I work on this SDK.

How to add an edge to existing and new vertices in gremlin-python?

I've already seen this answer:
Gremlin, How to add edge to existing vertex in gremlin-python
and it wasn't really helpful. As suggested in one of the comments I did try to update gremlinpython 3.3.0 but then I get key error.
Stack:
JanusGraph 0.2.0, gremlinpython3.2.3
This is my code
from gremlin_python import statics
from gremlin_python.structure.graph import Graph
from gremlin_python.process.graph_traversal import __
from gremlin_python.process.strategies import *
from gremlin_python.driver.driver_remote_connection import DriverRemoteConnection
graph = Graph()
g = graph.traversal().withRemote(DriverRemoteConnection('ws://localhost:8182/gremlin','g'))
martha = g.V().has('name','martha').next()
jack = g.V().has('name','jack').next()
#e_id = g.addE(jack,'likes',martha).next()
e_id = g.V(martha).as_('to').V(jack).addE("Likes").to('to').toList()
print e_id.toList()
StackTrace with gremlinpython 3.3.0
Traceback (most recent call last):
File "gremlin-py.py", line 9, in <module>
martha = g.V().has('name','martha').next()
File "/Users/arvindn/.virtualenvs/gremlinenv/lib/python2.7/site-packages/gremlin_python/process/traversal.py", line 70,in next
return self.__next__()
File "/Users/arvindn/.virtualenvs/gremlinenv/lib/python2.7/site-packages/gremlin_python/process/traversal.py", line 43,in __next__
self.traversal_strategies.apply_strategies(self)
File "/Users/arvindn/.virtualenvs/gremlinenv/lib/python2.7/site-packages/gremlin_python/process/traversal.py", line 352, in apply_strategies
traversal_strategy.apply(traversal)
File "/Users/arvindn/.virtualenvs/gremlinenv/lib/python2.7/site-packages/gremlin_python/driver/remote_connection.py", line 143, in apply
remote_traversal = self.remote_connection.submit(traversal.bytecode)
File "/Users/arvindn/.virtualenvs/gremlinenv/lib/python2.7/site-packages/gremlin_python/driver/driver_remote_connection.py", line 54, in submit
results = result_set.all().result()
File "/Users/arvindn/.virtualenvs/gremlinenv/lib/python2.7/site-packages/concurrent/futures/_base.py", line 429, in result
return self.__get_result()
File "/Users/arvindn/.virtualenvs/gremlinenv/lib/python2.7/site-packages/concurrent/futures/_base.py", line 381, in __get_result
raise exception_type, self._exception, self._traceback
KeyError: None
In my case, 3.3.0 is throwing error for all queries including g.V().next(). Now going back to 3.2.3, addvertex and other queries are working absolutely fine, but I couldn't figure out how to add edges. The same code when run with 3.2.3 produces,
StackTrace with gremlinpython 3.2.3
Traceback (most recent call last): File "gremlin-py.py", line 12, in <module>
e_id = g.V(martha).as_('to').V(jack).addE("Likes").to('to').toList()
File "/Users/arvindn/.virtualenvs/gremlinenv/lib/python2.7/site-packages/gremlin_python/process/traversal.py", line 52, in toList return list(iter(self))
File "/Users/arvindn/.virtualenvs/gremlinenv/lib/python2.7/site-packages/gremlin_python/process/traversal.py", line 70, in next
return self.__next__() File "/Users/arvindn/.virtualenvs/gremlinenv/lib/python2.7/site-packages/gremlin_python/process/traversal.py", line 43, in __next__
self.traversal_strategies.apply_strategies(self) File "/Users/arvindn/.virtualenvs/gremlinenv/lib/python2.7/site-packages/gremlin_python/process/traversal.py", line 284, in apply_strategies
traversal_strategy.apply(traversal)
File "/Users/arvindn/.virtualenvs/gremlinenv/lib/python2.7/site-packages/gremlin_python/driver/remote_connection.py", line 95, in apply remote_traversal = self.remote_connection.submit(traversal.bytecode) File "/Users/arvindn/.virtualenvs/gremlinenv/lib/python2.7/site-packages/gremlin_python/driver/driver_remote_connection.py", line 53, in submit traversers = self._loop.run_sync(lambda: self.submit_traversal_bytecode(request_id, bytecode))
File "/Users/arvindn/.virtualenvs/gremlinenv/lib/python2.7/site-packages/tornado/ioloop.py", line 457, in run_sync
return future_cell[0].result() File "/Users/arvindn/.virtualenvs/gremlinenv/lib/python2.7/site-packages/tornado/concurrent.py", line 237, in result
raise_exc_info(self._exc_info)
File "/Users/arvindn/.virtualenvs/gremlinenv/lib/python2.7/site-packages/tornado/gen.py", line 285, in wrapper
yielded = next(result)
File "/Users/arvindn/.virtualenvs/gremlinenv/lib/python2.7/site-packages/gremlin_python/driver/driver_remote_connection.py", line 69, in submit_traversal_bytecode
"gremlin": self._graphson_writer.writeObject(bytecode),
File "/Users/arvindn/.virtualenvs/gremlinenv/lib/python2.7/site-packages/gremlin_python/structure/io/graphson.py", line 72, in writeObject
return json.dumps(self.toDict(objectData), separators=(',', ':'))
File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/json/__init__.py", line 250, in dumps
sort_keys=sort_keys, **kw).encode(obj)
File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/json/encoder.py", line 207, in encode
chunks = self.iterencode(o, _one_shot=True)
File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/json/encoder.py", line 270, in iterencode
return _iterencode(o, 0)
File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/json/encoder.py", line 184, in default
raise TypeError(repr(o) + " is not JSON serializable")
TypeError: v[4184] is not JSON serializable
It says v[x] is not JSON serializable. I'm not sure what causes this error. It'll be awesome if someone can help. If any more info is needed, I shall update the question accordingly.
JanusGraph 0.2.0 uses Apache TinkerPop 3.2.6. You should use the 3.2.6 version of the gremlinpython driver.
pip uninstall gremlinpython
pip install gremlinpython==3.2.6

zope.annotation example in documentation fails. Help needed to correct it

I am trying to understand Annotations from this document:
http://docs.zope.org/zope.annotation/index.html
However the example fails when run.
I get:
Traceback (most recent call last):
File "./zopepy", line 366, in <module>
exec(compile(__file__f.read(), __file__, "exec"))
File "test1.py", line 29, in <module>
bar = IBar(foo)
File "eggs/zope.component-3.9.5-py2.7.egg/zope/component/_api.py", line 156, in adapter_hook
return sitemanager.queryAdapter(object, interface, name, default)
File "eggs/zope.component-3.9.5- py2.7.egg/zope/component/registry.py", line 228, in queryAdapter
return self.adapters.queryAdapter(object, interface, name, default)
File "eggs/zope.annotation-3.5.0-py2.7.egg/zope/annotation/factory.py", line 42, in getAnnotation
annotations = zope.annotation.interfaces.IAnnotations(context)
TypeError: ('Could not adapt', <__main__.Foo object at 0xb6d6956c>, <InterfaceClass zope.annotation.interfaces.IAnnotations>)
Example missing the following statements:
from zope.annotation.attribute import AttributeAnnotations
provideAdapter(AttributeAnnotations)

Resources