question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

TypeError: function() argument 'code' must be code, not str

See original GitHub issue

Situation:

# pip install twtxt
$ twtxt quickstart
Traceback (most recent call last):
  File "/usr/local/bin/twtxt", line 5, in <module>
    from twtxt.cli import main
  File "/usr/local/lib/python3.8/site-packages/twtxt/cli.py", line 29, in <module>
    from twtxt.twhttp import get_remote_tweets, get_remote_status
  File "/usr/local/lib/python3.8/site-packages/twtxt/twhttp.py", line 17, in <module>
    import aiohttp
  File "/usr/local/lib/python3.8/site-packages/aiohttp/__init__.py", line 6, in <module>
    from .client import *  # noqa
  File "/usr/local/lib/python3.8/site-packages/aiohttp/client.py", line 15, in <module>
    from . import connector as connector_mod
  File "/usr/local/lib/python3.8/site-packages/aiohttp/connector.py", line 12, in <module>
    from . import hdrs, helpers
  File "/usr/local/lib/python3.8/site-packages/aiohttp/helpers.py", line 742, in <module>
    class CeilTimeout(Timeout):
TypeError: function() argument 'code' must be code, not str

Environment:

$ uname -sr
OpenBSD 7.0

$ which python3
/usr/local/bin/python3

$ python3 -V
Python 3.8.12

Why?

Issue Analytics

  • State:closed
  • Created 2 years ago
  • Comments:6

github_iconTop GitHub Comments

1reaction
stxhcommented, Nov 22, 2021

1, Modify setup.py line 32 ‘aiohttp>=2.2.5,❤️’, to ‘aiohttp>=2.2.5,<4’, 2, pip install --upgrade aiohttp

0reactions
Ferryistakencommented, Sep 21, 2022

Same on Fedora 36

Traceback (most recent call last):
  File "/home/ferry/.local/bin//twtxt", line 5, in <module>
    from twtxt.cli import main
  File "/home/ferry/.local/lib/python3.10/site-packages/twtxt/cli.py", line 29, in <module>
    from twtxt.twhttp import get_remote_tweets, get_remote_status
  File "/home/ferry/.local/lib/python3.10/site-packages/twtxt/twhttp.py", line 17, in <module>
    import aiohttp
  File "/home/ferry/.local/lib/python3.10/site-packages/aiohttp/__init__.py", line 6, in <module>
    from .client import *  # noqa
  File "/home/ferry/.local/lib/python3.10/site-packages/aiohttp/client.py", line 15, in <module>
    from . import connector as connector_mod
  File "/home/ferry/.local/lib/python3.10/site-packages/aiohttp/connector.py", line 12, in <module>
    from . import hdrs, helpers
  File "/home/ferry/.local/lib/python3.10/site-packages/aiohttp/helpers.py", line 742, in <module>
    class CeilTimeout(Timeout):
TypeError: function() argument 'code' must be code, not str

Environment:

Linux 5.19.9-200.fc36.x86_64 
Python 3.10.6
Read more comments on GitHub >

github_iconTop Results From Across the Web

function() argument 1 must be code, not str - Stack Overflow
You're getting that exception because, despite its class-like name, threading.Condition is a function, and you cannot subclass functions.
Read more >
TypeError: function() argument 'code' must be code, not str ...
Hey, I'm running into this as well, looks related to newer version of async-timeout . ~ $ python3 -m venv env ~ $...
Read more >
TypeError: function() argument 'code' must be code, not str
When I run the script below, I get the following error: TypeError: function() argument 'code' must be code, not str.
Read more >
function() argument 'code' must be code, not str in Azure ...
I am having below data frame and wanted to save the data frame as a CSV file in the Azure Data lake. My...
Read more >
How to solve "function() argument 'code' must be code, not str"?
How to solve " function() argument ' code ' must be code, not str "? 392 views 1 year ago. Python Programming Channel....
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found