Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

'NoneType' object has no attribute 'close_client' #346

Open
congge27 opened this issue Dec 5, 2024 · 3 comments
Open

'NoneType' object has no attribute 'close_client' #346

congge27 opened this issue Dec 5, 2024 · 3 comments

Comments

@congge27
Copy link

congge27 commented Dec 5, 2024

  File "D:\python-pro\TikTokDownloader-master\TikTokDownloader-master\main.py", line 8, in main
    async with TikTokDownloader() as downloader:
  File "D:\python-pro\TikTokDownloader-master\TikTokDownloader-master\src\application\TikTokDownloader.py", line 104, in __aexit__
    await self.parameter.close_client()
          ^^^^^^^^^^^^^^^^^^^^^^^^^^^
AttributeError: 'NoneType' object has no attribute 'close_client'

python版本3.12.3
请问是啥情况

@sherlock-png
Copy link

sherlock-png commented Dec 6, 2024

我是macos,python版本3.13,也有这个报错,完整报错信息如下

❯ python main.py                                                              
>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>


              TikTokDownloader V5.4               


>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>

项目地址: https://github.com/JoeanAmier/TikTokDownloader
项目文档: https://github.com/JoeanAmier/TikTokDownloader/wiki/Documentation
开源许可: GNU General Public License v3.0

Traceback (most recent call last):
  File "/Users/yuto/Downloads/Code/github/TikTokDownloader-5.4/main.py", line 7, in main
    await downloader.run()
  File "/Users/yuto/Downloads/Code/github/TikTokDownloader-5.4/src/application/TikTokDownloader.py", line 324, in run
    await self.check_settings(False, )
  File "/Users/yuto/Downloads/Code/github/TikTokDownloader-5.4/src/application/TikTokDownloader.py", line 307, in check_settings
    self.parameter = Parameter(
                     ~~~~~~~~~^
        self.settings,
        ^^^^^^^^^^^^^^
    ...<4 lines>...
        recorder=self.recorder,
        ^^^^^^^^^^^^^^^^^^^^^^^
    )
    ^
  File "/Users/yuto/Downloads/Code/github/TikTokDownloader-5.4/src/config/parameter.py", line 170, in __init__
    self.client = create_client(timeout=self.timeout, **self.proxy, )
                  ~~~~~~~~~~~~~^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/yuto/Downloads/Code/github/TikTokDownloader-5.4/src/tools/session.py", line 31, in create_client
    return AsyncClient(
        headers=headers or {"User-Agent": user_agent, },
    ...<5 lines>...
        **kwargs,
    )
TypeError: AsyncClient.__init__() got an unexpected keyword argument 'proxies'

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/Users/yuto/Downloads/Code/github/TikTokDownloader-5.4/main.py", line 11, in <module>
    run(main())
    ~~~^^^^^^^^
  File "/opt/homebrew/Cellar/[email protected]/3.13.0_1/Frameworks/Python.framework/Versions/3.13/lib/python3.13/asyncio/runners.py", line 194, in run
    return runner.run(main)
           ~~~~~~~~~~^^^^^^
  File "/opt/homebrew/Cellar/[email protected]/3.13.0_1/Frameworks/Python.framework/Versions/3.13/lib/python3.13/asyncio/runners.py", line 118, in run
    return self._loop.run_until_complete(task)
           ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^^^^^^
  File "/opt/homebrew/Cellar/[email protected]/3.13.0_1/Frameworks/Python.framework/Versions/3.13/lib/python3.13/asyncio/base_events.py", line 721, in run_until_complete
    return future.result()
           ~~~~~~~~~~~~~^^
  File "/Users/yuto/Downloads/Code/github/TikTokDownloader-5.4/main.py", line 6, in main
    async with TikTokDownloader() as downloader:
               ~~~~~~~~~~~~~~~~^^
  File "/Users/yuto/Downloads/Code/github/TikTokDownloader-5.4/src/application/TikTokDownloader.py", line 101, in __aexit__
    await self.parameter.close_client()
          ^^^^^^^^^^^^^^^^^^^^^^^^^^^
AttributeError: 'NoneType' object has no attribute 'close_client'

@JoeanAmier
Copy link
Owner

使用 0.27.0 的 httpx 库。

@sherlock-png
Copy link

  File "D:\python-pro\TikTokDownloader-master\TikTokDownloader-master\main.py", line 8, in main
    async with TikTokDownloader() as downloader:
  File "D:\python-pro\TikTokDownloader-master\TikTokDownloader-master\src\application\TikTokDownloader.py", line 104, in __aexit__
    await self.parameter.close_client()
          ^^^^^^^^^^^^^^^^^^^^^^^^^^^
AttributeError: 'NoneType' object has no attribute 'close_client'

python版本3.12.3 请问是啥情况

谢谢作者的答复,已经解决了!

方法

pip uninstall httpx
pip install httpx==0.27.0

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants