google / UIforETW

User interface for recording and managing ETW traces
https://randomascii.wordpress.com/2015/04/14/uiforetw-windows-performance-made-easier/
Apache License 2.0
1.55k stars 201 forks source link

TypeError: 'dict_keys' object is not subscriptable in IdentifyChromeProcesses.py #104

Closed Ark-kun closed 6 years ago

Ark-kun commented 6 years ago

I've run UIforETW for the first time and used the Chrome developer mode as I wanted to investigate Chrome's CPU usage.

This is the error I saw in the Trace Information window:

Traceback (most recent call last): File "C:\UIforETW\bin\IdentifyChromeProcesses.py", line 136, in main() File "C:\UIforETW\bin\IdentifyChromeProcesses.py", line 88, in main for pid in pathByBrowserPid.keys()[:]: TypeError: 'dict_keys' object is not subscriptable

This does not seem to be a blocker for me. Just reporting.

randomascii commented 6 years ago

Thanks for the report. Apparently something went wrong with the script that identifies chrome processes, so you will be missing that information. I assume that you are running the latest release and I'm not aware of any bugs in it so there must have been something about the set of processes in your trace that triggered the bug. If you can share the trace then I should be able to repro the problem.

It's also possible that it is a Python3 specific bug since I only test on Python 2.7. Are you using Python 3?

randomascii commented 6 years ago

It's a Python 3 compatibility bug:

https://stackoverflow.com/questions/17322668/typeerror-dict-keys-object-does-not-support-indexing

randomascii commented 6 years ago

Should be fixed.

commit c01b535381837c9250405b5f453e5318209f4b1e Author: Bruce Dawson brucedawson@cygnus-software.com Date: Thu Jul 20 15:45:28 2017 -0700

Fix Python 3 compatibility bug

In Python 3 dict.keys() does not return a list. If you want to treat it
like a list you need to go list(dict.keys()). This change fixes issue
Shanzaay commented 4 years ago

I have tried many solutions but can't seem to solve the problem. This code is in Python 2.7 and I am using Python 3.7. While searching I find out that this gives an error in Python 3.7. Can anyone help me how to remove this error in Python 3.7?

      print('Loading c3d features ...')
            features = h5py.File(self._options['feature_data_path'], 'r') 
            self._feature_ids = features.keys()
            self._features = {video_id:np.asarray(features[video_id].values() [0]) for video_id in 
            self._feature_ids}

This is the error I am getting:

         E:\jupyter book\data_provider.py in <dictcomp>(.0)
         ---> 68         self._features 
       {video_id:np.asarray(features[video_id].values()[0]) for 
       video_id in self._feature_ids}
      69 
      70 

     TypeError: 'ValuesViewHDF5' object is not subscriptable
randomascii commented 4 years ago

The error messages you have included appear to have no relationship to IdentifyChromeProcesses.py. This is not a generic Python 3 support forum so you should ask for help elsewhere, perhaps on stackoverflow.