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.pycommand, 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.
You May have simple installed goslate, but you may be using different virtual env. Try to switch to that virtual env, and then run again.
Related
I installed PyTouchBar using pip3
When I tried to import it, however, it gives me this error.
$ python3
>>> import PyTouchBar
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages/PyTouchBar/__init__.py", line 5, in <module>
from .TouchBar import *
File "/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages/PyTouchBar/TouchBar.py", line 13, in <module>
from Foundation import *
ModuleNotFoundError: No module named 'Foundation'
On Python 2, Foundation works perfectly, by the way.
Could someone tell me how to fix this? Thanks in advance!
I think your problem could be one of these:
You installed PyTouchBar on python2 instead of python3, in which case you have to use:
pip3 install PyTouchBar
You are using a venv and installed from the terminal/command line instead of the venv's terminal
PyTouchBar uses foundation that you have to install separately
I'm using the latest version of Mephisto on macOS Catalina. I am trying to run ParlAI, and specifically the acute_eval task.
According to the Instructions of both Mephisto and AcuteEVAL, I should be able to execute run.py and get the task running. However, I get this error as I run it, using this command:
python run.py --pairings_filepath=example/pairings.jsonl
And this is the error:
Traceback (most recent call last):
File "run.py", line 17, in <module>
from parlai.crowdsourcing.tasks.acute_eval.acute_eval_blueprint import BLUEPRINT_TYPE
File "/Users/moli/opt/anaconda3/envs/py36/lib/python3.6/site-packages/parlai/crowdsourcing/tasks/acute_eval/acute_eval_blueprint.py", line 12, in <module>
from mephisto.core.registry import register_mephisto_abstraction
ModuleNotFoundError: No module named 'mephisto.core'
The ParlAI installation instructions on github state that Python 3.7 or higher is required, however it appears that you are using Python 3.6. This is likely the cause of the issue, and the program should work if you upgrade your Python version.
I have a Python script that I am trying to run in Linux via a bash script called ./launch.sh. When I launch the code I get the following error returned.
[user#localhost mktdata.out]$ ./launch.sh
[user#localhost mktdata.out]$ Traceback (most recent call last):
File "strats/merlin.py", line 10, in <module>
File "strats/merlin/mktdata.py", line 11, in <module>
File "strats/dao/utils/itertools.py", line 1, in <module>
ModuleNotFoundError: No module named 'future'
Line 1 in the Python script itertools.py line 1 that the error is referring to is:
from future.moves.itertools import zip_longest
Is there a package that I need to install in order for this code to work?
You need to import future like this:
from __future__ import *
In the event that fails, use pip to install it like this (Use sudo for MAC):
pip install future
Here is more on installing future.
I'm trying to run through the Guestbook tutorial on the google appengine website. I have Python 2.7.13 and Python 3.6 installed. However when I'm trying to run the program locally via dev_appserver.py ./ command I'm getting this error.
Traceback (most recent call last):
File "C:\Users\sameer\AppData\Local\Google\Cloud SDK\google-cloud-sdk\bin\dev_appserver.py", line 11, in <module>
import bootstrapping.bootstrapping as bootstrapping
File "C:\Users\sameer\AppData\Local\Google\Cloud SDK\google-cloud-sdk\bin\bootstrapping\bootstrapping.py", line 9, in <module>
import setup
ImportError: No module named 'setup'
I've tried installing and updating setuptools but it doesn't seem to work.
I have tried all the import methods and upgrading the libraries but still I'm unable to get over this error. I have downloaded and installed all the nltk and corpus data programmatically and it is working in the python shell but i'm getting error.
Traceback (most recent call last):
File "spark.py", line 7, in <module>
from textblob_aptagger import PerceptronTagger
File "/usr/local/lib/python2.7/dist-packages/textblob_aptagger/__init__.py", line 8, in <module>
from textblob_aptagger.taggers import PerceptronTagger
File "/usr/local/lib/python2.7/dist-packages/textblob_aptagger/taggers.py", line 10, in <module>
from textblob.packages import nltk
ImportError: No module named packages
Here's a pastebin to my code and imports..
Same error has been posted on github here. Use this instead to install textblob:
$ pip install -U git+https://github.com/sloria/textblob-aptagger.git#dev
Also, you should change from text.blob import TextBlob as tbto from textblob...
Works for me..