Importing keras-rl package into conda environment - github

I've installed keras-rl package on my computer, using their instructions:
git clone https://github.com/matthiasplappert/keras-rl.git
cd keras-rl
python setup.py install
So my conda environment sees this package, however when I am trying to import it in Spyder as a part of my code, i.e. import keras-rl, I get the following error:
SyntaxError: invalid syntax
with a pointer to the dash of keras-rl.
Question: How could I import the keras-rl (or any other package with the dash in the name) in Spyder?

We can install keras-rl by simply executing
pip install keras-rl
There are various functionalities from keras-rl that we can make use for running RL based algorithms in a specified environment
few examples below
from rl.agents.dqn import DQNAgent
from rl.policy import BoltzmannQPolicy
from rl.memory import SequentialMemory
This is how we can use the package.

If you look at the examples present in the github repository, you will see that the various functionalities are imported from rl. Like this:
(root) ~/condaexpts/keras-rl/examples $ grep -h import * | grep rl
from rl.agents import ContinuousDQNAgent
from rl.memory import SequentialMemory
from rl.random import OrnsteinUhlenbeckProcess
from rl.core import Processor
from rl.agents.cem import CEMAgent
from rl.memory import EpisodeParameterMemory
from rl.agents import DDPGAgent
from rl.memory import SequentialMemory
from rl.random import OrnsteinUhlenbeckProcess
from rl.agents.dqn import DQNAgent
from rl.policy import LinearAnnealedPolicy, BoltzmannQPolicy, EpsGreedyQPolicy
from rl.memory import SequentialMemory
from rl.core import Processor
from rl.callbacks import FileLogger, ModelIntervalCheckpoint
from rl.agents.dqn import DQNAgent
from rl.policy import BoltzmannQPolicy
from rl.memory import SequentialMemory

I had the same problem. After lots of examination I found the correct way.
You can import RL by writing this:
"import rl"
and then write your code like:
rl.core.Agent()

Related

ImportError: cannot import name 'compute_associations' from 'dython.nominal'

I just installed dython using pip install dython to use the tabsyndex. Here is the block of import
import pandas as pd
from tabsyndex import tabsyndex
from sklearn.model_selection import train_test_split
and it always shows
ImportError: cannot import name 'compute_associations' from 'dython.nominal'
Are there any way to import compute associations?
So far I tried reinstalling dython, but it always show the same error.

import name 'Mapping' from 'collections'

I have installed yfinance, but when i try to import it, it gives me the error: cannot import name 'Mapping' from 'collections'. I tried writing on jupyter notebook from collections.abs import Mappings, but it didn't work. I tried to look at the file init.py, but there is no: from collection import mapping, there is only import _collections_abc, and from _collections import deque.
Please help if someone has a solution?My python version is 3.10.5

import error for ibm_db using PyInstaller

How I can fix the bellow error?
I have a python code using GUI (tkinter) to get value and use the value to get data from ibm DB.
however, when I wanted to change it from py to exe using pyinstaller I get the bellow message:
my imports are:
import tkinter as tk
from tkinter import filedialog
import pandas as pd
import ibm_db
import ibm_db_dbi
import pandastable
from Calendar import Calendar
import numpy as np
import matplotlib.pyplot as plt
import calendar
import datetime
import sys
the code I am using
pyinstaller -F -w myfile.py
thanks $

Import Shutil module arttribute

I tried to use shutil module and copytree attribute. But it is not working and the commands box is empty. I import copytree and still not working.

Problem when importing package in scala

Suppose I have such packages:
package test
package test.views
package test.others
package views
Now in a scala file, I want to import test._ and views._(not test.views._), so I write:
import test._
import views._
But when I use some classes under views._, it reports type xxx not found, unless I change views package to another name.
What should I do now?
You can switch package import order (theoretically it should work):
import views._
import test._
Or you can be more precise in views import:
import _root_.views._
Here's yet another way (though using _root_ is the surest way to go):
import test.{views => testviews, _}
import views._