Error when using Kaggle CLI - python

I originally installed the official Kaggle CLI here a few weeks ago, and it was working fine. Now, however, whenever I try to pull a competition (or even list them) it appears to give me python errors. For example, when I put this:
$ kaggle competitions list
It gives me an attribute error and this traceback:
Traceback (most recent call last):
File "/home/ubuntu/src/anaconda3/envs/fastai/bin/kaggle", line 11, in <module>
sys.exit(main())
File "/home/ubuntu/src/anaconda3/envs/fastai/lib/python3.6/site-packages/kaggle/cli.py", line 48, in main
out = args.func(**command_args)
File "/home/ubuntu/src/anaconda3/envs/fastai/lib/python3.6/site-packages/kaggle/api/kaggle_api_extended.py", line 178, in competitions_list_cli
competitions = self.competitions_list(page, search)
File "/home/ubuntu/src/anaconda3/envs/fastai/lib/python3.6/site-packages/kaggle/api/kaggle_api_extended.py", line 175, in competitions_list
return [Competition(c) for c in competitions_list_result]
File "/home/ubuntu/src/anaconda3/envs/fastai/lib/python3.6/site-packages/kaggle/api/kaggle_api_extended.py", line 175, in <listcomp>
return [Competition(c) for c in competitions_list_result]
File "/home/ubuntu/src/anaconda3/envs/fastai/lib/python3.6/site-packages/kaggle/models/kaggle_models_extended.py", line 23, in __init__
parsed_dict = {k: parse(v) for k, v in init_dict.items()}
AttributeError: 'str' object has no attribute 'items'
I have tried to fix this by uninstalling and then reinstalling with pip, and when
that didn't work I went and manually deleted the site packages in the active virtualenv directory, but no luck.
Python Version 3.6.3 (Anaconda). Kaggle API version 1.3.12.
I'm not sure what changed from a few weeks ago! Any ideas? I'm probably doing something dumb.
Thanks a lot,
Alex

From the timing of your question, it looks like you may have hit a server glitch we were having. It should be fixed now. :)

Related

music21 write() function giving AttributeError: 'Rest' object has no attribute 'pitches' on python 3.9.1 and music21 version 7

I'm using the code found on this gist: https://gist.github.com/aldous-rey/68c6c43450517aa47474#file-transposer-py and when I run the script on MIDIs I have, including one from the author, I get the error
AttributeError: 'Rest' object has no attribute 'pitches'
It's quite old code, I had to modify a bit to fit python 3.9.1. I'm using the latest at this time music21 version 7. Was there any changes to the write() function that breaks this code?
EDIT: Here is the entire traceback:
Traceback (most recent call last):
File "C:\Users\username\path\to\transposer.py", line 28, in <module>
newscore.write('midi',newFileName)
File "C:\Users\username\AppData\Local\Programs\Python\Python39\lib\site-packages\music21\stream\base.py", line 328, in write
return super().write(fmt=fmt, fp=fp, **keywords)
File "C:\Users\username\AppData\Local\Programs\Python\Python39\lib\site-packages\music21\base.py", line 2665, in write
return formatWriter.write(self,
File "C:\Users\username\AppData\Local\Programs\Python\Python39\lib\site-packages\music21\converter\subConverters.py", line 1147, in write
mf = midiTranslate.music21ObjectToMidiFile(obj, **midiTranslateKeywords)
File "C:\Users\username\AppData\Local\Programs\Python\Python39\lib\site-packages\music21\midi\translate.py", line 260, in music21ObjectToMidiFile
return streamToMidiFile(music21Object, addStartDelay=addStartDelay)
File "C:\Users\username\AppData\Local\Programs\Python\Python39\lib\site-packages\music21\midi\translate.py", line 2559, in streamToMidiFile
midiTracks = streamHierarchyToMidiTracks(s,
File "C:\Users\username\AppData\Local\Programs\Python\Python39\lib\site-packages\music21\midi\translate.py", line 2443, in streamHierarchyToMidiTracks
subs.stripTies(inPlace=True, matchByPitch=False)
File "C:\Users\username\AppData\Local\Programs\Python\Python39\lib\site-packages\music21\stream\base.py", line 7283, in stripTies
endMatch = updateEndMatch(n)
File "C:\Users\username\AppData\Local\Programs\Python\Python39\lib\site-packages\music21\stream\base.py", line 7166, in updateEndMatch
and nLast is not None and len(nLast.pitches) == len(nInner.pitches)):
AttributeError: 'Rest' object has no attribute 'pitches'
Yes, this is a bug in version 7, but thanks to this report, I've opened a pull request to fix the issue.
There might be a bug-fix release this fall, or you could also just pull from the development version once the PR is merged, e.g. pip uninstall music21 and pip install git+https://github.com/cuthbertLab/music21.git. Thanks again for reporting!
I also faced the same problem. In my case I downgraded the version of music21 to version 6.7.1 and it started working like a charm. :)
pip install --upgrade music21==6.7.1

Python gives error in anaconda after update

I have just tried to upgrade everything in my main environment to the latest version (using conda update --all). Everything went completely fine until I actually tried to run python. I got this error message:
Traceback (most recent call last):
File "C:\Users\Ayush\Anaconda3\lib\site.py", line 579, in <module>
main()
File "C:\Users\Ayush\Anaconda3\lib\site.py", line 562, in main
known_paths = venv(known_paths)
File "C:\Users\Ayush\Anaconda3\lib\site.py", line 494, in venv
addsitepackages(known_paths, [sys.prefix])
File "C:\Users\Ayush\Anaconda3\lib\site.py", line 349, in addsitepackages
addsitedir(sitedir, known_paths)
File "C:\Users\Ayush\Anaconda3\lib\site.py", line 207, in addsitedir
addpackage(sitedir, name, known_paths)
File "C:\Users\Ayush\Anaconda3\lib\site.py", line 159, in addpackage
f = open(fullname, "r")
File "C:\Users\Ayush\Anaconda3\lib\_bootlocale.py", line 12, in getpreferredencoding
if sys.flags.utf8_mode:
AttributeError: 'sys.flags' object has no attribute 'utf8_mode'
As you can see, it looks like a problem with sys.flags. I tried googling this, but I couldn't find anyone with the same issue. I am using python 3.6.7 (python didn't update itself). This error message also appears if I try to run python in the command prompt. Here is the output of running conda update --all. Hope you can help!
EDIT: I found an issue on this issue on github here, but this doesn't give any explanations on how to fix this.
NOTE: I have also tried to install a new version of python using the installer, but that didn't work either.
I somehow did it - I re-installed Python, and then I tried using the command prompt, and it worked. It turned out that if I deleted my idea folder in Pycharm, it would work with the new version!

Django python Can not import FunctionType from module types

I am trying to use django channels and asgi to run a simple chat server. I have channels and daphne installed, but when I try to run the development server, I get the following error.
Unhandled exception in thread started by <function wrapper at 0x1062fdc80>
Traceback (most recent call last):
File "/Users/yash/code/lib/python2.7/site-packages/django/utils/autoreload.py", line 226, in wrapper
fn(*args, **kwargs)
File "/Users/yash/code/lib/python2.7/site-packages/channels/management/commands/runserver.py", line 63, in inner_run
"layer": self.channel_layer,
File "/Users/yash/code/lib/python2.7/site-packages/channels/asgi.py", line 86, in __str__
return "%s (%s)" % (self.alias, name_that_thing(self.channel_layer))
File "/Users/yash/code/lib/python2.7/site-packages/channels/utils.py", line 25, in name_that_thing
return name_that_thing(thing.__class__)
File "/Users/yash/code/lib/python2.7/site-packages/channels/utils.py", line 16, in name_that_thing
if hasattr(thing, "__class__") and not isinstance(thing, (types.FunctionType, types.MethodType)):
AttributeError: 'module' object has no attribute 'FunctionType'
I have checked out the last file and found that the error is with the types module. the line import types worked fine, but when the script trys to call types.FunctionType it gives an AttributeError. When I imported the script on the shell, It worked as expected
Any help is greatly appreciated. :)
EDIT
print(types) outputs:
<module 'types' from '/usr/local/Cellar/python/2.7.12_2/Frameworks/Python.framework/Versions/2.7/lib/python2.7/types.pyc'>
EDIT 2
I started another django project with channels, cloned a repository from github. When I ran the development server after installing dependencies, It worked perfectly. The channels utils file is the exact same, so any help explaining this would help.
I was browsing other StackOverflow questions and I found a common bug in python scripts where a badly named file caused a import error. I looked around in the channel installation directory and found a file named types.py and changed this to typer.py and the program worked as normal. Thanks for the help.

NSight gdb error

I have a problem with the "pretty printer" option of IDE NSight (eclipse) when I try to debug. I have googled but I have not found a solution to my problem.
When I start to debug, appears the next message:
Traceback (most recent call last):
File "/usr/share/gdb/auto-load/usr/lib/x86_64-linux-gnu/libstdc++.so.6.0.21-gdb.py", line 64, in <module>
register_libstdcxx_printers(gdb.current_objfile())
File "/usr/lib/x86_64-linux-gnu/../../share/gcc-5/python/libstdcxx/v6/__init__.py", line 33, in register_libstdcxx_printers
register_libstdcxx_xmethods(obj)
File "/usr/lib/x86_64-linux-gnu/../../share/gcc-5/python/libstdcxx/v6/xmethods.py", line 600, in register_libstdcxx_xmethods
gdb.xmethod.register_xmethod_matcher(locus, ArrayMethodsMatcher())
File "/usr/share/gdb/python/gdb/xmethod.py", line 266, in register_xmethod_matcher
index = _lookup_xmethod_matcher(locus, matcher.name)
File "/usr/share/gdb/python/gdb/xmethod.py", line 236, in _lookup_xmethod_matcher
for i in range(0, len(locus.xmethods)):
AttributeError: 'gdb.Objfile' object has no attribute 'xmethods'
I'm not sure where is the problem but the variables values doesn't appear and the only solution is to disable the pretty print option.
I'm using Ubuntu 16.04 and the cuda toolkit was installed from repositories.
If anyone can help, I will be very grateful.
This sounds like a bug in your gdb installation. gdb.Objfile.xmethods is something that should be provided by the gdb core, which implements gdb.Objfile. So, examining it from /usr/share/gdb/python/gdb/xmethod.py should be ok -- because that is also a file that comes with gdb.

Can not run robotframework-ride properly

I have installed robotframework-ride on two PCs of mine. Everything works fine on one PC but could not have RIDE running on other PC.
I have the following installed on both PCs
- Python 2.7.8 on win32
- Robot framework 2.8.6
- wxPython 2.8.12.1
- robotframeowkr-ride-1.4.1b
When I tried to execute "python ride.py" on the second PC, I got a message:
Traceback (most recent call last):
File "C:\Python27\lib\site-packages\robotide__init__.py", line 74, in main
run(inpath, not noupdatecheck, debug_console)
File "C:\Python27\lib\site-packages\robotide__init_.py", line 100, in run
ride = RIDE(inpath, updatecheck)
File "C:\Python27\lib\site-packages\robotide\application\application.py", line
41, in __init_
wx.App.init(self, redirect=False)
File "C:\Python27\lib\site-packages\wx-2.8-msw-unicode\wx_core.py", line 7981
, in init
self.BootstrapApp()
File "C:\Python27\lib\site-packages\wx-2.8-msw-unicode\wx_core.py", line 7555
, in _BootstrapApp
return _core.PyApp__BootstrapApp(args, *kwargs)
File "C:\Python27\lib\site-packages\robotide\application\application.py", line
49, in OnInit
self.namespace = Namespace(self.settings)
File "C:\Python27\lib\site-packages\robotide\namespace\namespace.py", line 41,
in init
self._set_pythonpath()
File "C:\Python27\lib\site-packages\robotide\namespace\namespace.py", line 62,
in _set_pythonpath
self._settings.get('installed robot version', None))
File "C:\Python27\lib\site-packages\robotide\namespace\robotlibraryloader.py",
line 35, in find_installed_robot_libraries
rf_file, rf_version = output.strip().split(', ')
ValueError: too many values to unpack
Use --help to get usage information.
Something more interesting is, if I uninstall robot framework from the second PC, I could execute "python ride.py" but of course there is no point doing this.
Anyone can help me out here?
With kind assistance from janne, I have solved this problem. The cause is for the first PC I installed the correct "robotframework", but for the second PC I managed to install a wrong module, "robot" instead of "robotframework". That was why RIDE was not working.
I am sorry for making such a silly mistake. A big thank you to janne for his help.
should use: pip install robotframework
should NOT use: pip install robot

Categories

Resources