AttributeError: 'NoneType' object has no attribute 'loader' urllib - request

I just started learning urllib and tried the request.urlopen method. However when I run it I come across this error:
from urllib import request
respons = request.urlopen("https://www.youtube.com/watch?v=LosIGgon_KM&ab_channel=Socratica")
Error processing line 1 of C:\Python310\lib\site-packages\matplotlib-3.5.2-py3.10-nspkg.pth:
Traceback (most recent call last):
File "C:\Python310\lib\site.py", line 186, in addpackage
exec(line)
File "", line 1, in
File "", line 568, in module_from_spec
AttributeError: 'NoneType' object has no attribute 'loader'
Remainder of file ignored

Related

volttron troubleshoot rpc call get_point

Any chance for a tip on how to troubleshoot a simple get_point rpc call to a BACnet device? Something I am doing on the rpc call throws this error: 'DriverAgent\' object has no attribute \'interface\'
This is my device:
vctl config get platform.driver registry_configs/33333.csv
That prints:
[
{
"Reference Point Name": "signal_payload",
"Volttron Point Name": "signal_payload",
"Units": "percent",
"Unit Details": "(default 0.0)",
"BACnet Object Type": "analogValue",
"Property": "presentValue",
"Writable": "FALSE",
"Index": "0",
"Write Priority": "",
"Notes": "Open ADR Payload Signal"
},
{
"Reference Point Name": "int_signal_duration",
"Volttron Point Name": "int_signal_duration",
"Units": "percent",
"Unit Details": "(default 0.0)",
"BACnet Object Type": "analogValue",
"Property": "presentValue",
"Writable": "FALSE",
"Index": "1",
"Write Priority": "",
"Notes": "Integer Signal Duration"
}
]
device address:
vctl config get platform.driver devices/slipstream_internal/slipstream_hq/33333
this will print:
{
"driver_config": {
"device_address": "10.200.200.224",
"device_id": 33333
},
"driver_type": "bacnet",
"registry_config": "config://registry_configs/33333.csv"
}
I think I have something wrong in my agent code in the dr_level = self.vip.rpc.call as shown in the snip below as the code errors out right after the ACTUATOR AGENT SCHEDULE SUCCESS:
dr_status = self.vip.rpc.call(
'platform.actuator', 'request_new_schedule', self.agent_id, 'my_test', 'HIGH', schedule_bac0_request).get(
timeout=4)
_log.info(f'*** [Setter Agent INFO] *** - ACTUATOR AGENT SCHEDULE SUCCESS')
dr_level = self.vip.rpc.call('platform.actuator','get_point', dr_topic, point="signal_payload").get(timeout=15)
the dr_topic is slipstream_internal/slipstream_hq/33333
Any ideas to try greatly appreciated...
Full traceback:
2021-06-15 14:36:27,597 (actuatoragent-1.0 403031) __main__ DEBUG: handle_get: slipstream_internal/slipstream_hq/33333
2021-06-15 14:36:27,598 (master_driveragent-4.0 403069) volttron.platform.vip.agent.subsystems.rpc ERROR: unhandled exception in JSON-RPC method 'get_point':
Traceback (most recent call last):
File "/var/lib/volttron/volttron/platform/vip/agent/subsystems/rpc.py", line 158, in method
return method(*args, **kwargs)
File "/home/volttron/.volttron/agents/55fbfb56-beac-4e6d-a201-1ab17b11d42b/master_driveragent-4.0/master_driver/agent.py", line 448, in get_point
return self.instances[path].get_point(point_name, **kwargs)
File "/home/volttron/.volttron/agents/55fbfb56-beac-4e6d-a201-1ab17b11d42b/master_driveragent-4.0/master_driver/driver.py", line 341, in get_point
return self.interface.get_point(point_name, **kwargs)
AttributeError: 'DriverAgent' object has no attribute 'interface'
2021-06-15 14:36:27,599 (actuatoragent-1.0 403031) volttron.platform.vip.agent.subsystems.rpc ERROR: unhandled exception in JSON-RPC method 'get_point':
Traceback (most recent call last):
File "/var/lib/volttron/volttron/platform/vip/agent/subsystems/rpc.py", line 158, in method
return method(*args, **kwargs)
File "/home/volttron/.volttron/agents/8f4ee1c0-74cb-4070-8a8c-57bf9bea8a71/actuatoragent-1.0/actuator/agent.py", line 897, in get_point
return self.vip.rpc.call(self.driver_vip_identity, 'get_point', path,
File "src/gevent/event.py", line 305, in gevent._gevent_cevent.AsyncResult.get
File "src/gevent/event.py", line 335, in gevent._gevent_cevent.AsyncResult.get
File "src/gevent/event.py", line 305, in gevent._gevent_cevent.AsyncResult.get
File "src/gevent/event.py", line 305, in gevent._gevent_cevent.AsyncResult.get
File "src/gevent/event.py", line 323, in gevent._gevent_cevent.AsyncResult.get
File "src/gevent/event.py", line 303, in gevent._gevent_cevent.AsyncResult._raise_exception
File "/var/lib/volttron/env/lib/python3.8/site-packages/gevent/_compat.py", line 66, in reraise
raise value
volttron.platform.jsonrpc.RemoteError: builtins.AttributeError("'DriverAgent' object has no attribute 'interface'")
2021-06-15 14:36:27,600 (setteroccvavagent-0.1 471606) volttron.platform.vip.agent.core ERROR: unhandled exception in periodic callback
Traceback (most recent call last):
File "/var/lib/volttron/volttron/platform/vip/agent/core.py", line 117, in _loop
method(*self.args, **self.kwargs)
File "/home/volttron/.volttron/agents/9c13ec66-7d7a-4f3d-a607-409a82e012ed/setteroccvavagent-0.1/setteroccvav/agent.py", line 252, in raise_setpoints_up
dr_level = self.vip.rpc.call('platform.actuator','get_point', dr_topic, point="signal_payload").get(timeout=4)
File "src/gevent/event.py", line 305, in gevent._gevent_cevent.AsyncResult.get
File "src/gevent/event.py", line 335, in gevent._gevent_cevent.AsyncResult.get
File "src/gevent/event.py", line 305, in gevent._gevent_cevent.AsyncResult.get
File "src/gevent/event.py", line 305, in gevent._gevent_cevent.AsyncResult.get
File "src/gevent/event.py", line 323, in gevent._gevent_cevent.AsyncResult.get
File "src/gevent/event.py", line 303, in gevent._gevent_cevent.AsyncResult._raise_exception
File "/var/lib/volttron/env/lib/python3.8/site-packages/gevent/_compat.py", line 66, in reraise
raise value
volttron.platform.jsonrpc.RemoteError: volttron.platform.jsonrpc.RemoteError('builtins.AttributeError("\'DriverAgent\' object has no attribute \'interface\'")')
driver = DriverAgent(self, contents, slot, self.driver_scrape_interval, topic,
group, self.group_offset_interval,
self.publish_depth_first_all,
self.publish_breadth_first_all,
self.publish_depth_first,
self.publish_breadth_first)
gevent.spawn(driver.core.run)
self.instances[topic] = driver
When the Platform Driver's configure method is called (which happens during a callback from the config store), the Platform Driver creates a driver instance with an interface class per the config that was passed. If the config that was passed is somehow incorrect or improperly passed, then the Platform Driver will be unable to actually instantiate the driver, and therefore it will not be added to the "self.instances" dictionary (above). When you make a call to the Platform Driver, you include a topic. That path MUST match the key that maps to the driver instance value in the "self.instances" dictionary.
As such, I have a couple of spots to suggest investigating. 1) Re-load the configs into the config store and watch the VOLTTRON log file as you do so. If you do not see a dictionary representation of the config file in the VOLTTRON log (while running in verbose logging mode) then you have likely given it an improperly formatted config. 2) Double check the topic you're using in your RPC calls. If the topic is not in the "self.instances" dictionary, it will throw an error as it's asking for a key that does not exist.
The configs you have posted above appear to me to be correct, so the topic in the RPC call or the commands used to store the configs appear to me to be the most likely culprits.
Actually what seemed to fix this is I restarted the actuator agent, bacnet proxy, and masteragent all at the same time. Was it maybe the master agent that needed a restart?
UPDATE
IF YOU HAD TO CHANGE SOMETHING IN THE CONFIG STORE FOR A DEVICE, for example make a BACnet point writeable instead of read ONLY; and something got fat fingered incorrectly this will ALSO CAUSE THE SAME ERROR! And also hard to troubleshoot.
For example on a live system if you had to modify something like this through vctl:
vctl config edit platform.driver registry_configs/1100.csv
And you create a syntax error with a fat finger this will also throw the same error!!!!!

S3 permission error when running sagemaker python sdk sklearn in local mode

I created a training script with hard coded input. It works as expected using a training job but I couldn't make it work using local mode.
It brings up a container on my local docker and exits with code (1)
Code:
estimator = SKLearn(entry_point="train_model.py",
train_instance_type="local")
estimator.fit()
Here is the exception:
2020-02-22 06:21:05,470 sagemaker-containers INFO Imported framework sagemaker_sklearn_container.training
2020-02-22 06:21:05,480 sagemaker-containers INFO No GPUs detected (normal if no gpus installed)
2020-02-22 06:21:05,504 sagemaker_sklearn_container.training INFO Invoking user training script.
2020-02-22 06:21:06,407 sagemaker-containers ERROR Reporting training FAILURE
2020-02-22 06:21:06,407 sagemaker-containers ERROR framework error:
Traceback (most recent call last):
File "/miniconda3/lib/python3.7/site-packages/sagemaker_containers/_trainer.py", line 81, in train
entrypoint()
File "/miniconda3/lib/python3.7/site-packages/sagemaker_sklearn_container/training.py", line 36, in main
train(framework.training_env())
File "/miniconda3/lib/python3.7/site-packages/sagemaker_sklearn_container/training.py", line 32, in train
training_environment.to_env_vars(), training_environment.module_name)
File "/miniconda3/lib/python3.7/site-packages/sagemaker_containers/_modules.py", line 301, in run_module
_files.download_and_extract(uri, _env.code_dir)
File "/miniconda3/lib/python3.7/site-packages/sagemaker_containers/_files.py", line 129, in download_and_extract
s3_download(uri, dst)
File "/miniconda3/lib/python3.7/site-packages/sagemaker_containers/_files.py", line 164, in s3_download
s3.Bucket(bucket).download_file(key, dst)
File "/miniconda3/lib/python3.7/site-packages/boto3/s3/inject.py", line 246, in bucket_download_file
ExtraArgs=ExtraArgs, Callback=Callback, Config=Config)
File "/miniconda3/lib/python3.7/site-packages/boto3/s3/inject.py", line 172, in download_file
extra_args=ExtraArgs, callback=Callback)
File "/miniconda3/lib/python3.7/site-packages/boto3/s3/transfer.py", line 307, in download_file
future.result()
File "/miniconda3/lib/python3.7/site-packages/s3transfer/futures.py", line 106, in result
return self._coordinator.result()
File "/miniconda3/lib/python3.7/site-packages/s3transfer/futures.py", line 265, in result
raise self._exception
File "/miniconda3/lib/python3.7/site-packages/s3transfer/tasks.py", line 255, in _main
self._submit(transfer_future=transfer_future, **kwargs)
File "/miniconda3/lib/python3.7/site-packages/s3transfer/download.py", line 345, in _submit
**transfer_future.meta.call_args.extra_args
File "/miniconda3/lib/python3.7/site-packages/botocore/client.py", line 357, in _api_call
return self._make_api_call(operation_name, kwargs)
File "/miniconda3/lib/python3.7/site-packages/botocore/client.py", line 661, in _make_api_call
raise error_class(parsed_response, operation_name)
botocore.exceptions.ClientError: An error occurred (403) when calling the HeadObject operation: Forbidden
An error occurred (403) when calling the HeadObject operation: Forbidden
tmpe_msr8pi_algo-1-kt1vh_1 exited with code 1
I found out that docker restart solved the issue.
After a while it happened again - and it solved it again.
I'm using docker for windows, and the issue is probably related to the created container configuration

Executable path error while using chrome driver with selenium

I am trying to open chrome using selenium but getting this error . I have tried many ways but still this issue is not resolved.
Traceback (most recent call last):
File "sl.py", line 11, in <module>
chrome.Initialize()
File "/home/daffolap/api_test/api_test/utils.py", line 14, in Initialize
driver = webdriver.Chrome(executable_path=r"/home/daffolap/api_test/chromedriver2.exe")
File "/usr/local/lib/python2.7/dist-packages/selenium/webdriver/chrome/webdriver.py", line 73, in __init__
self.service.start()
File "/usr/local/lib/python2.7/dist-packages/selenium/webdriver/common/service.py", line 83, in start
os.path.basename(self.path), self.start_error_message)
selenium.common.exceptions.WebDriverException: Message: 'chromedriver`enter code here`2.exe' executable needs to be in PATH. Please see https://sites.google.com/a/chromium.org/chromedriver/home
driver=None
class Webbrowser:
#staticmethod
def Initialize():
global driver
driver = webdriver.Chrome(executable_path=r"/home/daffolap/api_test/chromedriver2.exe")
driver.maximize_window()
driver.implicitly_wait(5)
return driver

PloneIDE intallation Error

Running buildout. This might take a while...
While:
Installing ploneide.
An internal error occurred due to a bug in either zc.buildout or in a
recipe being used:
Traceback (most recent call last):
File "/Plone/buildout-cache/eggs/zc.buildout-2.2.1-py2.7.egg/zc/buildout/buildout.py", line 1942, in main
getattr(buildout, command)(args)
File "/Plone/buildout-cache/eggs/zc.buildout-2.2.1-py2.7.egg/zc/buildout/buildout.py", line 622, in install
installed_files = self[part]._call(recipe.install)
File "/Plone/buildout-cache/eggs/zc.buildout-2.2.1-py2.7.egg/zc/buildout/buildout.py", line 1366, in _call
return f()
File "/Plone/zinstance/src/collective.recipe.ploneide/collective/recipe/ploneide/__init__.py", line 200, in install
self.install_developer_manual()
File "/Plone/zinstance/src/collective.recipe.ploneide/collective/recipe/ploneide/__init__.py", line 107, in install_developer_manual
res = subprocess.Popen(cmd, **kwargs)
File "/usr/lib/python2.7/subprocess.py", line 710, in __init__
errread, errwrite)
File "/usr/lib/python2.7/subprocess.py", line 1327, in _execute_child
raise child_exception
OSError: [Errno 2] No such file or directory
Buildout.cfg
develop =
src/collective.ploneide
src/collective.recipe.ploneide
parts=
ploneide
[Instance]
[ploneide]
recipe = collective.recipe.ploneide
ploneide may not be super well maintained at this point - last commit from 2012 https://github.com/collective/collective.ploneide
It would help if you posted your buildout.cfg and mentioned which OS you're using.

‘platform’ import disappearing from selenium as a result of my script

Linux ip-172-31-36-170 3.10.35-43.137.amzn1.x86_64 #1 SMP Wed Apr 2 09:36:59 UTC 2014 x86_64 x86_64 x86_64 GNU/Linux
Amazon Linux AMI release 2014.03
cpe:/o:amazon:linux:2014.03:ga
I've run into a weird problem with a script that uses selenium.webdriver.PhantomJS.
SYMPTOMS…
My script uses the following to start a phantomjs session
from selenium import selenium
from selenium import webdriver
from selenium.webdriver.common.keys import Keys
from selenium.webdriver.common.action_chains import ActionChains
(…)
def load_driver(self, _driver = "phantomjs", _path = "./phantomjs"):
if "phantom" in str(_driver).lower():
self.driver = webdriver.PhantomJS(_path)
Fails with:
selenium.common.exceptions.WebDriverException: Message: 'Unable to start phantomjs with ghostdriver.' ; Screenshot: available via screen
HOWEVER, at the python command line, everything works fine…
from selenium import webdriver
_path = './phantomjs.exe'
driver = webdriver.PhantomJS(_path)
PLATFORM: Linux
platform.system() != 'Windows': True
(I’ll explain “PLATFORM: Linux”, and “platform.system() != 'Windows': True” below)
SO…
I traced the error to the “/usr/lib/python2.6/site-packages/selenium/webdriver/phantomjs/service.py” and specifically this code…
def start(self):
"""
"""
try:
print "PLATFORM:", platform.system() #ADDED BY ME
# FOLLOWING ADDED BY ME, NOW CAUSING THE ERROR
print "platform.system() != 'Windows': ", platform.system() != 'Windows'
self.process = subprocess.Popen(self.service_args, stdin=subprocess.PIPE,
close_fds=platform.system() != 'Windows', # <-- THIS CAUSED ORIG PROB
stdout=self._log, stderr=self._log)
except Exception as e:
raise WebDriverException("Unable to start phantomjs with ghostdriver.", e)
AND HERE’S THE ISSUE…
When I run the code at the python command line (see above) everything is fine, AND the responses to ‘platform.system()’ and “platform.system() != 'Windows' ” are correct.
However, when I run my script, the ‘platform.system()’ reports blank and “platform.system() != 'Windows' ” errors. (See actual output below).
So, for some reason, when my script loads selenium and runs…THE SELENIUM CODE loses the ‘platform’ import.
Thanks for the help!
ACTUAL OUTPUT BELOW (NOTICE that 'PLATFORM:' is followed by 'blank' (instead of 'Linux'), and the next line “platform.system() != 'Windows' ” triggers the error. These lines were added by me into the SELENIUM code, not my code!)
PLATFORM:
Traceback (most recent call last):
File "./agmarknet.py", line 834, in <module>
username = options.username # --username
File "./agmarknet.py", line 124, in __init__
self.load_driver(driver, driver_path)
File "./agmarknet.py", line 521, in load_driver
self.driver = webdriver.PhantomJS(_path)
File "/usr/lib/python2.6/site-packages/selenium/webdriver/phantomjs/webdriver.py", line 50, in __init__
self.service.start()
File "/usr/lib/python2.6/site-packages/selenium/webdriver/phantomjs/service.py", line 64, in start
print "PLATFORM:", platform.system() #333
File "/usr/lib64/python2.6/platform.py", line 1272, in system
return uname()[0]
File "/usr/lib64/python2.6/platform.py", line 1239, in uname
processor = _syscmd_uname('-p','')
File "/usr/lib64/python2.6/platform.py", line 995, in _syscmd_uname
output = string.strip(f.read())
File "./agmarknet.py", line 350, in _signal_handler
self._cleanup()
File "./agmarknet.py", line 194, in _cleanup
self.driver.close()
AttributeError: 'Agmarknet' object has no attribute 'driver'
2014-05-18 12:42:40,281 - Agmarknet - INFO - Closing WebDriver...
Error in atexit._run_exitfuncs:
Traceback (most recent call last):
File "/usr/lib64/python2.6/atexit.py", line 24, in _run_exitfuncs
func(*targs, **kargs)
File "./agmarknet.py", line 194, in _cleanup
self.driver.close()
AttributeError: 'Agmarknet' object has no attribute 'driver'
Error in sys.exitfunc:
Traceback (most recent call last):
File "/usr/lib64/python2.6/atexit.py", line 24, in _run_exitfuncs
func(*targs, **kargs)
File "./agmarknet.py", line 194, in _cleanup
self.driver.close()

Resources