I am trying Goslate: Free Google Translate API. I installed goslate using sudo pip install goslate
I wrote a simple program and executed it using python getbn.py
command in my terminal.
Here is the code inside getbn.py
:
import goslate
gs = goslate.Goslate()
print(gs.translate('hello world', 'bn'))
After executing the command python getbn.py
I got the following errors:
Traceback (most recent call last):
File "getbn.py", line 1, in <module>
import goslate
File "/home/ubuntu/Desktop/goslate.py", line 2, in <module>
# -*- coding: utf-8 -*-
AttributeError: 'module' object has no attribute 'Goslate'
Then I tried to run the program by executing python3 getbn.py
command, and I found the following errors:
Traceback (most recent call last):
File "getbn.py", line 1, in <module>
import goslate
ImportError: bad magic number in 'goslate': b'\x03\xf3\r\n'
How do I fix it? And why are there two different types of erros?
You have a file called goslate.py
in your Desktop
folder
File "/home/ubuntu/Desktop/goslate.py", line 2, in <module>
^^^^^^^^^^^^^^^^^^^^
This is not the module you installed using pip
and it's getting in the way of the import.