ERROR: post() got an unexpected keyword argument ‘proxies’

I’m using youtube-search-python to get the URLs of an array with song names but this error keeps popping up:

post() got an unexpected keyword argument 'proxies'

I’m new to Python and I’ve been looking around but I couldn’t find nothing useful for fixing this error (at least that I understood).

This is the code that is throwing the error:

 elif "open.spotify.com" == url_procesed.hostname:

        try: 
            playlist = Playlist(client_id, client_secret)
            playlist_tracks = playlist.get_playlist_tracks(url)
            link_list = playlist.search_for_songs(playlist_tracks)
            print(link_list)

Here’s the error stack trace:

Traceback (most recent call last):
  File "G:Bot_v1.1.2spoty_handler.py", line 69, in <module>
    playlist.search_for_songs(song_array)
  File "G:Bot_v1.1.2spoty_handler.py", line 48, in search_for_songs
    search = VideosSearch(song, limit=1)
             ^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "C:UsersTarjetaCiudadanaAppDataLocalPackagesPythonSoftwareFoundation.Python.3.12_qbz5n2kfra8p0LocalCachelocal-packagesPython312site-packagesyoutubesearchpythonsearch.py", line 148, in __init__
    self.sync_create()
  File "C:UsersTarjetaCiudadanaAppDataLocalPackagesPythonSoftwareFoundation.Python.3.12_qbz5n2kfra8p0LocalCachelocal-packagesPython312site-packagesyoutubesearchpythoncoresearch.py", line 29, in sync_create
    self._makeRequest()
  File "C:UsersTarjetaCiudadanaAppDataLocalPackagesPythonSoftwareFoundation.Python.3.12_qbz5n2kfra8p0LocalCachelocal-packagesPython312site-packagesyoutubesearchpythoncoresearch.py", line 51, in _makeRequest
    request = self.syncPostRequest()
              ^^^^^^^^^^^^^^^^^^^^^^
  File "C:UsersTarjetaCiudadanaAppDataLocalPackagesPythonSoftwareFoundation.Python.3.12_qbz5n2kfra8p0LocalCachelocal-packagesPython312site-packagesyoutubesearchpythoncorerequests.py", line 20, in syncPostRequest
    return httpx.post(
           ^^^^^^^^^^^
TypeError: post() got an unexpected keyword argument 'proxies'

The error must be in playlist.search_for_songs because it doesn’t print anything. Here is the code for all of it:

import os

import spotipy
from spotipy.oauth2 import SpotifyClientCredentials

from pytube import YouTube
from youtubesearchpython import VideosSearch

from dotenv import load_dotenv

class Playlist:
    
    def __init__(self, client_id, client_secret):

        
        self.client_id = client_id
        self.client_secret = client_secret

        load_dotenv()
        
    def get_playlist_tracks(self, playlist_url):
        
        auth_manager = SpotifyClientCredentials(client_id=self.client_id, client_secret=self.client_secret)
        sp = spotipy.Spotify(auth_manager=auth_manager)
        
        results = sp.playlist_tracks(playlist_url)
        artists_songs_dict = []

        
        for item in results['items']:

            track = item['track']
            song_name = track['name']

            #artist_names = [artist['name'] for artist in track['artists']]
            artists_songs_dict.append(song_name)     

        return artists_songs_dict 

    def search_for_songs(self, song_dict):
        link_list = []
        
        for songs in song_dict:
            
            for song in songs:
                
                search = VideosSearch(song, limit=1)
                results = search.result()
                link = results['result'][0]['link']
                link_list.append(link)
                
        return link_list
        
TOKEN_1 = os.getenv("MY_TOKEN_1")
TOKEN_2= os.getenv("MY_TOKEN_2")

playlist= Playlist(client_id, client_secret)
song_array= playlist.get_playlist_tracks("https://open.spotify.com/playlist/0drb98YI5Kk0ENtWXIS67y?si=bEHhpXlUThSyKkxNxkMCeg")
playlist.search_for_songs(song_array)

I believe you are using httpx version 0.28.0 or above (not consciously, I guess, but as part of another package). In this version, the post method really doesn’t have the proxies parameter declared. Compare this:

>>> httpx.__version__
'0.27.2'
>>> 'proxies' in inspect.getargs(httpx.post.__code__).args
True

versus

>>> httpx.__version__
'0.28.1'
>>> 'proxies' in inspect.getargs(httpx.post.__code__).args
False

You might want to consider downgrading httpx to version 0.27 if possible, like so:

pip install --force-reinstall 'httpx<0.28'

I think a reasonable approach would be to try it in a fresh, separate environment first.

4

Trang chủ Giới thiệu Sinh nhật bé trai Sinh nhật bé gái Tổ chức sự kiện Biểu diễn giải trí Dịch vụ khác Trang trí tiệc cưới Tổ chức khai trương Tư vấn dịch vụ Thư viện ảnh Tin tức - sự kiện Liên hệ Chú hề sinh nhật Trang trí YEAR END PARTY công ty Trang trí tất niên cuối năm Trang trí tất niên xu hướng mới nhất Trang trí sinh nhật bé trai Hải Đăng Trang trí sinh nhật bé Khánh Vân Trang trí sinh nhật Bích Ngân Trang trí sinh nhật bé Thanh Trang Thuê ông già Noel phát quà Biểu diễn xiếc khỉ Xiếc quay đĩa Dịch vụ tổ chức sự kiện 5 sao Thông tin về chúng tôi Dịch vụ sinh nhật bé trai Dịch vụ sinh nhật bé gái Sự kiện trọn gói Các tiết mục giải trí Dịch vụ bổ trợ Tiệc cưới sang trọng Dịch vụ khai trương Tư vấn tổ chức sự kiện Hình ảnh sự kiện Cập nhật tin tức Liên hệ ngay Thuê chú hề chuyên nghiệp Tiệc tất niên cho công ty Trang trí tiệc cuối năm Tiệc tất niên độc đáo Sinh nhật bé Hải Đăng Sinh nhật đáng yêu bé Khánh Vân Sinh nhật sang trọng Bích Ngân Tiệc sinh nhật bé Thanh Trang Dịch vụ ông già Noel Xiếc thú vui nhộn Biểu diễn xiếc quay đĩa Dịch vụ tổ chức tiệc uy tín Khám phá dịch vụ của chúng tôi Tiệc sinh nhật cho bé trai Trang trí tiệc cho bé gái Gói sự kiện chuyên nghiệp Chương trình giải trí hấp dẫn Dịch vụ hỗ trợ sự kiện Trang trí tiệc cưới đẹp Khởi đầu thành công với khai trương Chuyên gia tư vấn sự kiện Xem ảnh các sự kiện đẹp Tin mới về sự kiện Kết nối với đội ngũ chuyên gia Chú hề vui nhộn cho tiệc sinh nhật Ý tưởng tiệc cuối năm Tất niên độc đáo Trang trí tiệc hiện đại Tổ chức sinh nhật cho Hải Đăng Sinh nhật độc quyền Khánh Vân Phong cách tiệc Bích Ngân Trang trí tiệc bé Thanh Trang Thuê dịch vụ ông già Noel chuyên nghiệp Xem xiếc khỉ đặc sắc Xiếc quay đĩa thú vị
Trang chủ Giới thiệu Sinh nhật bé trai Sinh nhật bé gái Tổ chức sự kiện Biểu diễn giải trí Dịch vụ khác Trang trí tiệc cưới Tổ chức khai trương Tư vấn dịch vụ Thư viện ảnh Tin tức - sự kiện Liên hệ Chú hề sinh nhật Trang trí YEAR END PARTY công ty Trang trí tất niên cuối năm Trang trí tất niên xu hướng mới nhất Trang trí sinh nhật bé trai Hải Đăng Trang trí sinh nhật bé Khánh Vân Trang trí sinh nhật Bích Ngân Trang trí sinh nhật bé Thanh Trang Thuê ông già Noel phát quà Biểu diễn xiếc khỉ Xiếc quay đĩa
Thiết kế website Thiết kế website Thiết kế website Cách kháng tài khoản quảng cáo Mua bán Fanpage Facebook Dịch vụ SEO Tổ chức sinh nhật