ValueError: unsupported pickle protocol: 5 eventhough I have installed pickle5 - python-3.x

I am running a python 3.7 conda environment and I have imported pickle5 into my code however I am still getting the following error regardless:
C:\Users\Joel\Desktop\Bowls App Object Detection>python obj.py
Using TensorFlow backend.
Generating anchor boxes for training images and annotation...
Traceback (most recent call last):
File "obj.py", line 7, in
trainer.setTrainConfig(object_names_array=["white bowls, black bowls, yellow bowls"], batch_size=4, num_experiments=100, train_from_pretrained_model="pretrained-yolov3.h5")
File "C:\Users\Joel\anaconda3\envs\py37\lib\site-packages\imageai\Detection\Custom_init_.py", line 171, in setTrainConfig
self.__train_cache_file, self.__model_labels)
File "C:\Users\Joel\anaconda3\envs\py37\lib\site-packages\imageai\Detection\Custom\gen_anchors.py", line 82, in generateAnchors
model_labels
File "C:\Users\Joel\anaconda3\envs\py37\lib\site-packages\imageai\Detection\Custom\voc.py", line 9, in parse_voc_annotation
cache = pickle.load(handle)
ValueError: unsupported pickle protocol: 5
It would be great if someone could help out!

Related

Python3 ArcPy path/permissions setting error sd Hosted Services

Traceback (most recent call last):
File "<string>", line 34, in <module>
File "C:\Program Files\ArcGIS\Pro\Resources\ArcPy\arcpy\mp.py", line 105, in CreateWebLayerSDDraft
return _convertArcObjectToPythonObject(arcgisscripting._mapping.CreateWebLayerSDDraft(*_gp_fixargs([map_or_layers, out_sddraft, service_name, server_type, service_type, folder_name, overwrite_existing_service, copy_data_to_server, enable_editing, allow_exporting, enable_sync, summary, tags, description, credits, use_limitations], True)))
ValueError: Staging path is invalid or inaccessible: C:\Users\hagerty_finn\Documents\ArcGIS\Projects\TrafficFatalityCount\temp.txt
Line 34:
arcpy.mp.CreateWebLayerSDDraft(mp, sddraft, sd_fs_name, 'MY_HOSTED_SERVICES', 'FEATURE_ACCESS')
I tried changing the file path to another user and updating the password. The problem persists. I am running this script in ArcGIS Pro Python window on a GIS local server.

Running a python file to train GAN using reinforcement learning

I'm reading the Deep Reinforcement Learning Hands-On book by Maxim Lapan but have trouble running code here. I get the following error when running this file. I'm new to ubuntu's command line and PyTorch but I'm familiar to Deep Learning. Please help me solve this problem. Thank you!
I tried to run this file using python 03_atari_gan.py
How do I pass 'mode' while running the program?
Thanks!
INFO: Making new env: Breakout-v0 INFO: Making new env: AirRaid-v0
Traceback (most recent call last): File "03_atari_gan.py", line 138,
in
envs = [InputWrapper(gym.make(name)) for name in ('Breakout-v0', 'AirRaid-v0', 'Pong-v0')] File "03_atari_gan.py", line 138, in
envs = [InputWrapper(gym.make(name)) for name in ('Breakout-v0', 'AirRaid-v0', 'Pong-v0')] File
"/home/sandesh/rl/lib/python3.6/site-packages/gym/envs/registration.py",
line 156, in make
return registry.make(id, kwargs) File "/home/sandesh/rl/lib/python3.6/site-packages/gym/envs/registration.py",
line 101, in make
env = spec.make(**kwargs) File "/home/sandesh/rl/lib/python3.6/site-packages/gym/envs/registration.py",
line 73, in make
env = cls(_kwargs) File "/home/sandesh/rl/lib/python3.6/site-packages/gym/envs/atari/atari_env.py",
line 69, in init
self.seed() File "/home/sandesh/rl/lib/python3.6/site-packages/gym/envs/atari/atari_env.py",
line 98, in seed
).format(self.game_mode, self.game, modes) AssertionError: Invalid game mode "0" for game air_raid. Available modes are: [1 2 3 4 5 6 7
8]

AttributeError: module 'resource' has no attribute 'getpagesize'

I am trying to use Tensorflow Object Detection API and I follow the steps mentioned in the given link -
https://tensorflow-object-detection-api-tutorial.readthedocs.io/en/latest/install.html#tf-models-install
When I try to access the Object Detection Jupyter Notebook through jupyter notebook
I am facing the below exception
Traceback (most recent call last):
File "/usr/local/bin/jupyter-notebook", line 7, in <module>
from notebook.notebookapp import main
File "/home/dinesh/.local/lib/python3.6/site-
packages/notebook/notebookapp.py", line 79, in <module>
from .base.handlers import Template404, RedirectWithParams
File "/home/dinesh/.local/lib/python3.6/site-
packages/notebook/base/handlers.py", line 32, in <module>
import prometheus_client
File "/home/dinesh/.local/lib/python3.6/site-
packages/prometheus_client/__init__.py", line 7, in <module>
from . import process_collector
File "/home/dinesh/.local/lib/python3.6/site-
packages/prometheus_client/process_collector.py", line 12, in <module>
_PAGESIZE = resource.getpagesize()
AttributeError: module 'resource' has no attribute 'getpagesize'
I am using
Python - 3.6.3
Jupyter - 1.0.0
How can I overcome this exception?
Got a similar error. My project contained modules (folders)
model
resource (replaced with resources)
service
So I changed the name of the resource module to resources (change name to any appropriate module name)
I have the same error ,after rename my resource module in the PYTHONPATH , it works right. check your PYTHONPATH, is there a resource module?
I had a similar issue on starting Jupyter Notebooks on Windows 10.
When I initially ran the regular startup script, I got a windows terminal that opened and immediately closed, too fast to see any error messages. So, I opened a windows 10 powershell terminal and ran
conda update conda
and
conda update --all
then I ran
jupyter-notebook at the windows prompt. The results were:
Traceback (most recent call last):
File "E:\Users\Bob\anaconda3\Scripts\jupyter-notebook-script.py", line 6, in
from notebook.notebookapp import main
File "E:\Users\Bob\anaconda3\lib\site-packages\notebook\notebookapp.py", line 76, in
from .base.handlers import Template404, RedirectWithParams
File "E:\Users\Bob\anaconda3\lib\site-packages\notebook\base\handlers.py", line 24, in
import prometheus_client
File "E:\Users\Bob\anaconda3\lib\site-packages\prometheus_client_init_.py", line 3, in
from . import (
File "E:\Users\Bob\anaconda3\lib\site-packages\prometheus_client\process_collector.py", line 11, in
_PAGESIZE = resource.getpagesize()
AttributeError: module 'resource' has no attribute 'getpagesize'
I opened process_collector.py in the site-packages\prometheus_client in notepad++ and changed
line 9 import resource to import resources
and
line 11 _PAGESIZE = resource.getpagesize() to _PAGESIZE = resources.getpagesize()
I searched for other instances of resource and found none. I then saved the file and reran jupyter-notebook at the windows terminal prompt.
This time I got:
Traceback (most recent call last):
File "E:\Users\Bob\anaconda3\Scripts\jupyter-notebook-script.py", line 10, in
sys.exit(main())
File "E:\Users\Bob\anaconda3\lib\site-packages\jupyter_core\application.py", line 254, in launch_instance
return super(JupyterApp, cls).launch_instance(argv=argv, **kwargs)
File "E:\Users\Bob\anaconda3\lib\site-packages\traitlets\config\application.py", line 844, in launch_instance
app.initialize(argv)
File "E:\Users\Bob\anaconda3\lib\site-packages\traitlets\config\application.py", line 87, in inner
return method(app, *args, **kwargs)
File "E:\Users\Bob\anaconda3\lib\site-packages\notebook\notebookapp.py", line 2126, in initialize
self.init_resources()
File "E:\Users\Bob\anaconda3\lib\site-packages\notebook\notebookapp.py", line 1697, in init_resources
old_soft, old_hard = resource.getrlimit(resource.RLIMIT_NOFILE)
AttributeError: module 'resource' has no attribute 'getrlimit'
Still having Notepad++ open, I opened notebookapp.py in site-packages\notebook and searched for resource. I found and changed the following lines:
Line 37 import resource to import resources
line 40 resource = None to resources = None
line 1036 resource is None to resources is None
line 1040 soft, hard = resource.getrlimit(resource.RLIMIT_NOFILE) to
soft, hard = resources.getrlimit(resources.RLIMIT_NOFILE)
line 1693 if resource is None: to if resources is None:
line 1697 old_soft, old_hard = resource.getrlimit(resource.RLIMIT_NOFILE) to old_soft, old_hard = resources.getrlimit(resources.RLIMIT_NOFILE)
line 1706 resource.setrlimit(resource.RLIMIT_NOFILE, (soft, hard)) to
resources.setrlimit(resources.RLIMIT_NOFILE, (soft, hard))
I searched for other instances of resource and found none. I then saved the notebookapp.py file and reran jupyter-notebook at the windows terminal prompt. This time Jupyter Notebooks opened with the expected files tab displayed. I quit out of Jupyter Notebooks and restarted using the normal link to the startup script and it worked as expected.
I am not sure what caused this issue. I did not intentionally update anything before I saw the issue. Yesterday, Jupyter Notebooks worked as expected, today when I tried to run it, I got the flicker screen as described above.
[Quick look for root cause]
Check if you have set PYTHONPATH in your system -
try to rename that momentarily
run "jupyter notebook"
[Fix the issue]
if the issue is resolved by doing this then
search "resource" folder within all paths mentioned in PYTHONPATH
if such folder found then rename/refactor it to other name e.g. "resources"

Speech recognition library is giving error of input device

I am doing voice recognition using python library "Speech Recognition",Every thing is going well with audio files but when i use mike, it is showing this error.
Traceback (most recent call last):
File "StoTUsingMike.py", line 5, in <module>
with sr.Microphone() as source:
File "/home/nash/.local/lib/python3.5/site-packages/speech_recognition/__init__.py", line 86, in __init__
device_info = audio.get_device_info_by_index(device_index) if device_index is not None else audio.get_default_input_device_info()
File "/usr/local/lib/python3.5/dist-packages/pyaudio.py", line 949, in get_default_input_device_info
device_index = pa.get_default_input_device()
OSError: No Default Input Device Available
I have seen 2 or 3 more posts regarding this error on stack overflow but there is no clear solution.
Kindly help me out of this problem.

Strange invalid pickle protocol errors when using Dill

Recently, Dill has completely stopped working for me. It does this:
>>> import dill
>>> dill.dumps([1,2,3])
b'\x80\x03]q\x00(K\x01K\x02K\x03e.'
>>> dill.loads(_)
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "C:\Python34\lib\site-packages\dill\dill.py", line 260, in loads
return load(file)
File "C:\Python34\lib\site-packages\dill\dill.py", line 250, in load
obj = pik.load()
File "C:\Python34\lib\pickle.py", line 1039, in load
dispatch[key[0]](self)
File "C:\Python34\lib\pickle.py", line 1066, in load_proto
raise ValueError("unsupported pickle protocol: %d" % proto)
ValueError: unsupported pickle protocol: 93
The number is different every time. This started happening maybe a month ago; reinstalling Dill with pip didn't help.
From stepping through it with a debugger it looks like it's correctly reading in the protocol version from the beginning of the data, then reading one of the first instructions in the pickle data and interpreting it as the protocol version for some reason. I don't really know though, since I don't know much about how pickle works.

Resources