No module named 'ray.rllib.agents.ppo.ppo_policy' - python

I have this code:
from copy import deepcopy
import json
import ray
try:
from ray.rllib.agents.agent import get_agent_class
except ImportError:
from ray.rllib.agents.registry import get_agent_class
from ray.rllib.agents.ppo.ppo_policy import PPOTFPolicy
from ray import tune
from ray.tune.registry import register_env
from ray.tune import run_experiments
I am getting the error:
No module named 'ray.rllib.agents.ppo.ppo_policy'
I tried:
pip install ray;

I re installed the system and reconfigured the environment to solve this problem

Related

Module installed but not imported

I’m trying to install and import the modules who are missing in a python script before it shows error.
try:
import matplotlib
import numpy
except ImportError as e:
import os
module = e.name
os.system(‘pip install ‘+ module)
import module
The errors I get : ModuleNotFound : No module named “matplotlib”
import module ModuleNotFoundError: No module named “module”
Although the module gets installed correctly, when I rerun it again, the script recognizes the installed modules and works fine. Any idea what it could be?
I think these functions will solve it. I use importlib because if you try to import like import module python sees it like there is a module named module not matplotlib. So, you need to use importlib.import_module() to overcome this situation.
import os
import sys
def library_installer(name):
"""
Install a library from the pip package manager.
"""
import subprocess
subprocess.call([sys.executable, "-m", "pip", "install", name])
def library_importer(name):
"""
Import a library from the pip package manager.
"""
import importlib
return importlib.import_module(name)
try:
import e
except ImportError as x:
library_installer(x.name)
library_installer(x.name)
Here is a link for importlib if you want.

ModuleNotFoundError: No module named 'Session'

When I run my python script file.py, I get an error ModuleNotFoundError: No module named 'Session'.
The imports on my script:
import os
import sys
import tensorflow as tf
import numpy as np
import random
import time
import requests
from requests import Request, Session
from flask_session import Session
from flask_session.__init__ import Session
import Session
from setup_inception import ImageNet, InceptionModel
You should not use from flask_session import Session
Instead use from flask_session.__init__ import Session
I'm sorry for the late answer, I have solved the problem with command:
import tensorflow.compat.v1 as tf
instead of
import tensorflow as tf
because I 'm using tensorflow 2.4

Python3.8 Import Error No module name tqdm found

I'm trying to run this python project on my linux machine. I did setup everything according to the requirement but when I try to run the project with the ./generate.sh executable file I got the following error.
Import Error: No module name tqdm found.
Here are the imports exists in file.
import os.path as path
import ast
from glob import glob
import signal
import imp
import logging
import time
import numpy as np
import socket
import tqdm
import sys
import click
import tensorflow as tf
from tensorflow.python.client import timeline
I check with pip3 show tqdm command it shows me the package detail. I also try to uninstall and install again the project but got no luck.
If i remove the tqdm import from the file then it shows me this error.
File "./run.py", line 16, in <module>
import click
ImportError: No module named click
Can someone guide me what I'm doing wrong here?
it seems you are importing it wrong, from tqdm docs:
from tqdm import tqdm
I've checked it for both python2 and 3 and this is the way to use it.
The project you are trying to use at least 3 years old, so maybe things have changed since then, so if it wont work for you even with proper import statement you can simply remove it.
Every loop working with tqdm will work without it as well.
For example:
from tqdm import tqdm
for i in tqdm(range(10000)):
pass
is the same as:
for i in range(10000)):
pass

Cannot import utils.programs but import utils successfully - python3 import error

I am trying to implement the code in https://github.com/kexinyi/ns-vqa.
However, when I try the command, python tools/preprocess_questions.py \ ... in the section of "Getting started". I see a message No module named 'utils.programs'.
Then I install utils and which makes import utils work, but import utils.programs does not work.
Does anyone have any idea to solve it?
import os
import argparse
import json
import h5py
import numpy as np
import utils.programs as program_utils # this one cannot be imported
import utils.preprocess as preprocess_utils
import utils.utils as utils
Solution:
Add the below lines at the beginning of preprocess_questions.py file.
import sys
sys.path.insert(0, "..")
This should solve your problem.
Explanation:
It is failing because preprocess_questions.py don't know about the path of utils.programs to import. With the above lines added to the path using .., the required file will be imported.
For more on this refer how importing works in python.

ImportError: No module named deepmolecule.rdkit_utils

When I tried to python running,
I got the error that
ImportError: No module named deepmolecule.rdkit_utils
so I search about "deepmolecule.rdkit_utils" at google, but there are no exist about that module information.
How can I solve this problem?
This is importing modules in the python script file.
import csv
import subprocess
import numpy as np
import numpy.random as npr
import matplotlib.pyplot as plt
import copy
from deepmolecule.rdkit_utils import smile_to_fp
from rdkit.Chem import Descriptors
from rdkit import Chem
from rdkit.Chem import rdMolDescriptors
Apparently, the module got renamed to neuralfingerprint and is called nfp at pypi. Hence, you can install the module by running pip install nfp in your shell. Note that you might need to change the name of the module in your script.

Categories