Cannot import gym_wrapper for ACME, any solution? - python

Import of acme is successfull, but not able to find gym wrapper class
import acme
from acme.wrappers import gym_wrapper
Error Message while running
ModuleNotFoundError Traceback (most recent call last)
\<ipython-input-4-9d5212a1080d\> in \<module\>()
1 # reinforcement learning
2 import acme
\----\> 3 from acme.wrappers import gym_wrapper
4 from acme.environment_loop import EnvironmentLoop
5 from acme.utils.loggers import TerminalLogger, InMemoryLogger
ModuleNotFoundError: No module named 'acme.wrappers'
---------------------------------------------------------------------------
NOTE: If your import is failing due to a missing package, you can
manually install dependencies using either !pip or !apt.
Any alternative api for gym_wrapper in ACME framework?

I think you forget to install dm-acme environment module.
It's clearly stated in the section 3. of installation process
pip install dm-acme[envs]

Related

Unable to import nonsense from Nostril

I am trying to import nonsense from Nostril (
from nostril import nonsense)
but I get this error;
ImportError Traceback (most recent call last)
Cell In [12], line 1
----> 1 from nostril import nonsense
ImportError: cannot import name 'nonsense' from 'nostril' (c:\Users\GithuaG\AppData\Local\Programs\Python\Python310\lib\site-packages\nostril\__init__.py)
Here is what the init.py file contains:
from .__version__ import __version__, __title__, __url__, __description__
from .__version__ import __author__, __email__
from .__version__ import __license__, __copyright__
from .ng import NGramData
from .nonsense_detector import (
nonsense, generate_nonsense_detector, test_unlabeled, test_labeled,
ngrams, dataset_from_pickle, sanitize_string
)
Tried researching on the web but no success.
Any help will be appreciated, Thanks
You most probably did pip install nostril before you installed the actual nostril package that you needed (just like I did). This would have caused another package that is used for testing to be installed alongside. You can either uninstall both nostril packages and then re-install just the nostril package you need.
Or you can directly import the nonsense object from nonsense_detector as below if you need both the packages
from nostril.nonsense_detector import nonsense

ModuleNotFoundError: No module named 'thinc.neural'

I'm having trouble running my code, here are the results of the error I got :
--------------------------------------------------------------------------- ModuleNotFoundError Traceback (most recent call last) <ipython-input-35-d0706627a935> in <module>
1 # import the function to train using spaCy
----> 2 from train_spacy import train_spacy
~\TA\train_spacy.py in <module>
3 from spacy.util import minibatch, compounding
4 from spacy.util import decaying
----> 5 from thinc.neural.optimizers import Adam
6 import random
7 from matplotlib import pyplot as plt
ModuleNotFoundError: No module named 'thinc.neural'
The following are the related modules installed on my OS.
C:\Users\Anonymous>pip list | findstr spacy spacy 3.0.5 spacy-legacy 3.0.1 C:\Users\Anonymous>pip list | findstr thinc thinc 8.0.2
If there are other statements that I have not explained, please ask me, and I ask for your help because I have tried to reinstall the module but are still facing the same error, and I apologize if my language is wrong. Thank you ^ - ^
Since a few versions ago thinc was reorganized. Classes and functions should now be imported from thinc.api.
As you can see, Adam is referenced in https://github.com/explosion/thinc/blob/master/thinc/api.py.

google colab. It gives this error when I execute the training code

It gives this error when I execute the training code.
ModuleNotFoundError
Traceback (most recent call last)
<ipython-input-12-08472a50f5e6> in <module>()
6 import logging
7 logging.getLogger('tensorflow').disabled = True
----> 8 import input_data
9 import resnet_utils
10 import resnet_v2
ModuleNotFoundError: No module named 'input_data'
---------------------------------------------------------------------------
NOTE: If your import is failing due to a missing package, you can
manually install dependencies using either !pip or !apt.
To view examples of installing some common dependencies, click the
"Open Examples" button below.

Google Cloud Natural Language Import Error

I am having a lot of trouble with getting the Google Cloud Natural Language API running. I am trying to run a Python program in Linux on a Google VM. I am also unsure of how to run a full Traceback of the error. The following code is not working:
from google.cloud import language
from google.cloud.language import enums
from google.cloud.language import types.
On Python 2 I get the error:
Traceback (most recent call last):
File "natlangex.py", line 3, in <module>
from google.cloud.language import enums
ImportError: cannot import name enums
I tried upgrading to Python 3 and when I run Python 3 I get the error:
And I updated to Python 3. One thing that is confusing is that when I run Python 3 the error is a bit different:
Traceback (most recent call last):
File "natlangex.py", line 2, in <module>
from google.cloud import language
ImportError: No module named 'google'
Here are the other things I have tried:
I installed the SDK.
I set export GOOGLE_APPLICATION_CREDENTIALS="apikey.json".
I tried !pip install google-cloud-language
I upgraded pip pip install --upgrade setuptools pip.
I am very lost! Thank you in advance.
It seems that you are using wrong syntax because of the library update, you may refer now to the new one, following [1] and more specifically [2].
It seems that the official Natural Language documentation of Google Cloud is not updated yet [3], but at the end of this documentation you have links to the Python Client Library [1][2] where it explains the changes.
Your imports should be:
from google.cloud import language_v1
from google.cloud.language_v1 import enums
from google.cloud.language_v1 import types
[1] https://googleapis.dev/python/language/latest/api.html
[2] https://googleapis.dev/python/language/latest/gapic/v1/api.html
[3] https://cloud.google.com/natural-language/docs/reference/libraries#client-libraries-usage-python

How to fix "cannot import name 'get_seomoz_data' from 'api' " error in Python

I have tried to get the Alexa ranking for a given website. I used PyPI's seolib library and installed it in my environment using !pip install seolib --user command. After executing alexa_rank = seolib.get_alexa('http://google.com') code line, I got the following error.
ModuleNotFoundError: No module named 'api'
Then I installed api module using !pip install api --user command. Then after I got this import error and I don't have an idea of how to solve this error. Please somebody help on this.
import seolib
alexa_rank = seolib.get_alexa('http://google.com')
print(alexa_rank)
ImportError Traceback (most recent call last)
<ipython-input-21-b46efa0fce9a> in <module>
----> 1 import seolib
2
3 alexa_rank = seolib.get_alexa('http://google.com')
4 print(alexa_rank)
~/.local/lib/python3.7/site-packages/seolib/__init__.py in <module>
4
5
----> 6 from api import get_seomoz_data
7 from api import get_alexa
8 from api import get_semrush
ImportError: cannot import name 'get_seomoz_data' from 'api' (/home/mylap/.local/lib/python3.7/site-packages/api/__init__.py)
I'm using Python 3.7.3 version on my environment.
seolib version 0.1.3, last release was in 2013 year. Homepage returns error 404. Doesn't look good. Old, outdated, abandoned.
The code from api import was relative import in Python 2.7, changed to absolute import in Python 3. Overall the code seems to be Python2-only.

Categories