Gcobani Mkontwana

Gcobani Mkontwana

  • 568
  • 1.9k
  • 406.7k

from googletrans import translate error module

Mar 2 2023 11:37 PM

Hi Team

 

I have a small issue, the code is fine but the problem is with the module its throwing an error below. What i did was pip install googletrans, because i am using data frame to translate language from English to Hindi. How can i fix this issue?



all_courses = driver.find_element(by=By.CLASS_NAME, value='catalog-grid__results')
courses = all_courses.find_elements(by=By.CSS_SELECTOR, value='[class="color-charcoal course-name"]')

df = pd.DataFrame([[course.text, course.get_attribute('')] for course in courses],
                    columns=['Title (eng)', 'Link'])

df['Title (hin)'] = df['Title (eng)'].apply(lambda x: translate(x, dest='hi').text)// Before the error was unference name translate(then install pip install translate, the new error now is because of this first fix.

print('{0} and {1}'.format('course.text', 'Title'))

from google_translate import translate

// pycharm exception from terminal


 File \main.py", line 1, in <module>
    from google_translate import translate
 packages\google_translate.py", line 119
    print translation.encode(encoding)
    ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
SyntaxError: Missing parentheses in call to 'print'. Did you mean print(...)?

 


Answers (2)