Getting OSError when running script - python

I am trying to set up the ChirpSDK, but every time I configure and run the code, I get this error:
Traceback (most recent call last):
File "test.py", line 3, in <module>
chirp = ChirpSDK()
File "/Library/Frameworks/Python.framework/Versions/3.8/lib/python3.8/site-packages/chirpsdk/chirpsdk.py", line 395, in __init__
self.read_chirprc(block)
File "/Library/Frameworks/Python.framework/Versions/3.8/lib/python3.8/site-packages/chirpsdk/chirpsdk.py", line 501, in read_chirprc
raise IOError('Could not find a ~/.chirprc file')
OSError: Could not find a ~/.chirprc file
Exception ignored in: <function ChirpSDK.__del__ at 0x10fa31af0>
Traceback (most recent call last):
File "/Library/Frameworks/Python.framework/Versions/3.8/lib/python3.8/site-packages/chirpsdk/chirpsdk.py", line 422, in __del__
self.close()
File "/Library/Frameworks/Python.framework/Versions/3.8/lib/python3.8/site-packages/chirpsdk/chirpsdk.py", line 470, in close
if self._sdk:
AttributeError: 'ChirpSDK' object has no attribute '_sdk'
I realize that the error is saying that my .chirprc file is not being recognized, but I have no idea how to remedy this. I created a .chirprc file in my /Users/username/ path, and named it c.chirprc (as the Chirp getting started article suggests), but I am still getting this error. Is there another part that I am missing? Am I reading the instructions wrong?
Thanks

The Chirp configuration file should be placed at /Users/<username>/.chirprc on macOS.
If you run ls -l ~/.chirprc in the terminal, do you get any results? If it displays no such file or directory then you have not created the file correctly.

Related

troubleshooting python script from github

1) python newbie
2) tasked with getting a script together that would compile various stats from our brocade switches
trying to run this script
https://github.com/zapman449/brocade_switchshow_aliases
3) get it set up per the Readme. Config file is set up (I think) properly)
4) BUT - I get the following errors - and not sure why. Any help would be appreciated
[someguy#myserver SAN_Scripts]$ ./get-brocade.py fcr_fd_41
<function parse_switch_line at 0x1429578>
Switch Username: someguy
Switch password for user someguy:
Traceback (most recent call last):
File "./get-brocade.py", line 265, in <module>
main()
File "./get-brocade.py", line 261, in main
get_switchshow(conn, switch)
File "./get-brocade.py", line 198, in get_switchshow
if len(words) == 3 :
TypeError: object of type 'NoneType' has no len()
Exception in thread Thread-1 (most likely raised during interpreter shutdown):
Traceback (most recent call last):
File "/usr/lib64/python2.6/threading.py", line 532, in __bootstrap_inner
File "/usr/lib/python2.6/site-packages/paramiko/transport.py", line 1609, in run
<type 'exceptions.AttributeError'>: 'NoneType' object has no attribute 'error'
[someguy#myserverSAN_Scripts]$

Error exporting inference graph (ValueError)

So I'm following sentdex's object detection tutorial and I have gotten to the step where you are supposed to export the inference graph. I'm using the "export_inference_graph.py" script from Tensorflow's object_detection folder.
The problem is that I'm getting this ValueError:
Traceback (most recent call last):
File "C:\Users\Zelcore-Dator\AppData\Local\Programs\Python\Python35\lib\site-packages\google\proto
buf\internal\python_message.py", line 545, in _GetFieldByName
return message_descriptor.fields_by_name[field_name]
KeyError: 'layout_optimizer'
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "export_inference_graph.py", line 119, in <module>
tf.app.run()
File "C:\Users\Zelcore-Dator\AppData\Local\Programs\Python\Python35\lib\site-packages\tensorflow\p
ython\platform\app.py", line 48, in run
_sys.exit(main(_sys.argv[:1] + flags_passthrough))
File "export_inference_graph.py", line 115, in main
FLAGS.output_directory, input_shape)
File "C:\Users\Zelcore-Dator\AppData\Local\Programs\Python\Python35\lib\site-packages\object_detec
tion-0.1-py3.5.egg\object_detection\exporter.py", line 427, in export_inference_graph
input_shape, optimize_graph, output_collection_name)
File "C:\Users\Zelcore-Dator\AppData\Local\Programs\Python\Python35\lib\site-packages\object_detec
tion-0.1-py3.5.egg\object_detection\exporter.py", line 391, in _export_inference_graph
initializer_nodes='')
File "C:\Users\Zelcore-Dator\AppData\Local\Programs\Python\Python35\lib\site-packages\object_detec
tion-0.1-py3.5.egg\object_detection\exporter.py", line 72, in freeze_graph_with_def_protos
layout_optimizer=rewriter_config_pb2.RewriterConfig.ON)
File "C:\Users\Zelcore-Dator\AppData\Local\Programs\Python\Python35\lib\site-packages\google\proto
buf\internal\python_message.py", line 484, in init
field = _GetFieldByName(message_descriptor, field_name)
File "C:\Users\Zelcore-Dator\AppData\Local\Programs\Python\Python35\lib\site-packages\google\proto
buf\internal\python_message.py", line 548, in _GetFieldByName
(message_descriptor.name, field_name))
ValueError: Protocol message RewriterConfig has no "layout_optimizer" field.
I'm guessing that it has something to do with protobuf, but I've reinstalled it several times already with no success.
All help appreciated
Happened to me too. Didn't happen few weeks ago.
Until the bug is fixed, you could use an earlier version that still works.
replace line 72 in 'object_detection/exporter.py':
layout_optimizer=rewriter_config_pb2.RewriterConfig.ON)
with the old and working line:
optimize_tensor_layout=True)
I used:
rewrite_options = rewriter_config_pb2.RewriterConfig(optimize_tensor_layout=True)
but kept running into the same issue UNTIL I went and reran
python setup.py install
from my "research" folder. Then I was able to get everything to work.
Remove optimize_tensor_layout=rewriter_config_pb2.RewriterConfig.ON
change the line 71 in exporter.py
rewrite_options = rewriter_config_pb2.RewriterConfig(optimize_tensor_layout=rewriter_config_pb2.RewriterConfig.ON)
to:
rewrite_options = rewriter_config_pb2.RewriterConfig()

ImportError: No module named __main__ (Python 2.7 & Pickle)

So on my game I'm making, I'm trying to load the data files needed for the game, and when I load the file with pickle (The file has been loaded, I've double-checked that.) I get this error:
Traceback (most recent call last):
File "/Users/user/Downloads/Deeper-master/Deeper.py", line 257, in <module>
tutorialData = pickle.load(tutorialFile)
File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/pickle.py", line 1384, in load
return Unpickler(file).load()
File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/pickle.py", line 864, in load
dispatch[key](self)
File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/pickle.py", line 1075, in load_inst
klass = self.find_class(module, name)
File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/pickle.py", line 1130, in find_class
__import__(module)
ImportError: No module named __main__
I saw a question like this on Stack Overflow, but it's a little different than my situation, so sorry if this is a duplicate, I'm just trying to figure it out.
You can find my code here. The main script is Deeper.py, just to save time.
If you notice in your repo, you have a Deeper.pyc and Deeper.py. If I run Deeper.py, it raises the same exception as yours. If I run Deeper.pyc, it raises another exception:
Traceback (most recent call last):
File "Deeper.py", line 7, in <module>
ToolbarTile = pygame.image.load("ToolbarTile.png")
pygame.error: Couldn't open Toolbar Tile.png
So, the code (bytecode, some previous version) references ToolbarTile.png, but the exception is about Toolbar Tile.png (with a space). So I changed the file name to account for that.
Now it raises:
Traceback (most recent call last):
File "Deeper.py", line 766, in <module>
else:
File "Deeper.py", line 394, in __init__
def displayCraft(self):
pygame.error: Couldn't open options.png
There's an Options.png in your files, but it looks for options.png (lower case) (even your new code in Deeper.py looks for that). So I changed that.
Now it works, albeit with Deeper.pyc so that must be why you thought:
(The file has been loaded, I've double-checked that.)
Maybe delete the Deeper.pyc and do a git-bisect to see when the bug was introduced (ps: check your toolbar.dat, does it seem okay to you? Also check the way you're using pickle.load. Maybe you should use rb instead of r?)

Python code not working from cron job but works from command line via virtualenv

I am receiving different errors which I cannot determine the issue. It seems as though it has to do with the configparser.py NoSectionError(section). This code runs fine from the command line in the virtualenv.
Traceback (most recent call last):
File "/usr/lib/python3.5/configparser.py", line 1135, in _unify_values
sectiondict = self._sections[section]
KeyError: 'token'
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "/home/lvensel/projects/worklion01/worklion01/wl_cron.py", line 15, in <module>
wl_post_projects.post()
File "/home/lvensel/projects/worklion01/worklion01/wl_post_projects.py", line 15, in post
import wl_get_background_jobs
File "/home/lvensel/projects/worklion01/worklion01/wl_get_background_jobs.py", line 12, in <module>
oauth, token = wl_secure_token.fetch_token()
File "/home/lvensel/projects/worklion01/worklion01/wl_secure_token.py", line 17, in fetch_token
values = wl_get_ini.get_values()
File "/home/lvensel/projects/worklion01/worklion01/wl_get_ini.py", line 13, in get_values
'token_url': config.get('token', 'token_url'),
File "/usr/lib/python3.5/configparser.py", line 778, in get
d = self._unify_values(section, vars)
File "/usr/lib/python3.5/configparser.py", line 1138, in _unify_values
raise NoSectionError(section)
configparser.NoSectionError: No section: 'token'
Let me guess on what potentially happens:
Cron jobs are run by root
virtualenv is run by your user with a custom python environment.
root does not know about your virtualenv, then cannot match your user's python environment, thus your script fails. Probably with some cannot import or alike errors.
Have a look at replies here.

Pyglet file name "Resource not found"

I'm trying to open a music track and add it to a queue for a player in Pyglet.
def QueueAudio(self):
self.musicpath=filedialog.askopenfilename()
print(self.musicpath)
Player.queue(pyglet.resource.media(r"self.musicpath"))
The musicpath variable works fine as the print statement prints the filename. The error comes when the player tries to queue the track. Error below.
Exception in Tkinter callback
Traceback (most recent call last):
File "C:\Python33\lib\site-packages\pyglet\resource.py", line 605, in media
location = self._index[name]
KeyError: 'self.musicpath'
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "C:\Python33\lib\tkinter\__init__.py", line 1475, in __call__
return self.func(*args)
File "C:\Users\Rob\Google Drive\Coursework\Part 2\music player tests\test5.py", line 99, in QueueAudio
self.playerpath=pyglet.resource.media(r"self.musicpath")
File "C:\Python33\lib\site-packages\pyglet\resource.py", line 615, in media
raise ResourceNotFoundException(name)
pyglet.resource.ResourceNotFoundException: Resource "self.musicpath" was not found on the path. Ensure that the filename has the correct captialisation.
Does anyone know why this is, and what may fix it?
This line looks to be the culprit:
self.playerpath=pyglet.resource.media(r"self.musicpath")
You are passing a string "self.musicpath" to a function, when you should be passing in the contents of a variable named self.musicpath. You need to call it like this:
self.playerpath = pyglet.resource.media(self.musicpath)

Categories

Resources