I have a problem when importing some dependencies from stable baselines 3 library, I installed it with this command
pip install stable-baselines3[extra]
But When I import my dependencies
import gym
from stable_baselines3 import A2C
from stable_baselines3.common.vec_env import VecFrameStackFrame
from stable_baselines3.common.evaluation import evaluate_policy
from stable_baselines3.common.env_util import make_atari_env
import os
I face this error
ImportError: cannot import name 'VecFrameStackFrame' from 'stable_baselines3.common.vec_env' (C:\Users\User\anaconda3\envs\rl_learning\lib\site-packages\stable_baselines3\common\vec_env\__init__.py)
Any advice?
I knew that stable baselines new version has changed the name from
from stable_baselines3.common.vec_env import VecFrameStackFrame
To
from stable_baselines3.common.vec_env import vec_frame_stack
and it worked for me
Related
Now I am setting a new environment to work with a script that has the following packages:
import platform
import sys
import os
import re
import shutil
import numpy as np
import datetime
from osgeo import osr
from osgeo import gdal
from math import sin, cos, pi, tan
import time
import subprocess
import numpy.polynomial.polynomial as poly
from openpyxl import load_workbook
from pyproj import Proj, transform
import warnings
I am trying to install the packages using anaconda GUI, but I could not find the "osgeo" or "osr" or "numpy.polynomial.polynomial"
Can anyone help me or give me an alternative to quickly set the environment?
I selected all other packages like that
enter image description here
I have a problem with Google Colab, it crashes. When I try to import libraries, this system log appears:
WARNING:root:kernel 550fdef7-0cf5-47e7-86a7-8a6a019a6aaa restarted
KernelRestarter: restarting kernel (1/5), keep random ports
Kernel interrupted: 550fdef7-0cf5-47e7-86a7-8a6a019a6aaa
I looked for the answer in other posts and checked that the Ram was free (it is), but importing one library at a time I discovered that the problem is given by torch_geometric, what could I do? To install the libraries I use this code:
!pip install -q torch torchvision
!pip install torch-scatter torch-sparse torch-cluster torch- spline-conv torch-geometric -f https://data.pyg.org/whl/torch-1.10.0+cpu.html
!pip install import-ipynb
!pip install networkx
!pip install rdkit-pypi
!pip install deepchem
!pip install -q dgl
!pip install gdown -U --no-cache-dir
The libraries I'm trying to import are these:
# Usefull libreries to load and process the data
import pandas as pd
import numpy as np
import matplotlib.pyplot as plt
from sklearn.exceptions import ConvergenceWarning
from sklearn.metrics import accuracy_score
from sklearn.svm import LinearSVC
import import_ipynb
import warnings
import os
import os.path as osp
from tqdm import tqdm
# Usefull libresies to create and work on graph
import torch
import torch_geometric
import torch.nn.functional as F
from torch_geometric.loader import DataLoader
from torch_geometric import data
from torch_geometric.data import Data, Dataset, Batch
import torch_geometric.utils
from torch.nn import Linear, BatchNorm1d, ReLU, Sequential
import torch.nn.functional as F
from torch_geometric.nn import global_mean_pool, GCNConv, GINConv, WLConv, GAE
from torch_geometric.nn.glob.glob import global_mean_pool
import networkx as nx
# Useful libraries to visualize chemical structures and calculate chemical properties
import rdkit
from rdkit import Chem
from rdkit.Chem import Draw
from rdkit.Chem.rdMolDescriptors import CalcMolFormula
import deepchem as dc
# Notebook
from graph_converter import MoleculeDataset
from Utils import formula, draw_molecule, activity
Thanks to all!
I am using Python 3.6.8 on Windows 10
I installed tensorflow, keras, and utils using pip.
pip install tensorflow and it installs the version 2.0.0
pip install keras and it installs the version 2.3.1
pip install utils but it does not show what version I have installed.
This is my header:
from keras.preprocessing import image
from PIL import Image
from keras.models import model_from_json, load_model
import numpy as np
import cv2
from datetime import datetime
import os
import random
import string
from utils.datasets import get_labels
from utils.inference import apply_offsets
from utils.inference import load_detection_model
from utils.preprocessor import preprocess_input
This is my error:
from utils.datasets import get_labels
ModuleNotFoundError: No module named 'utils.datasets'
Why am I getting this error? And how to fix it? BTW The code was written by a previous programmer and I need to modify it. But I can't even run it. not so good in python tho. i'm just getting started to it.
All my google search are all purple but I can't seem to find any solutions.
EDIT
The suggested answer (ImportError: No module named datasets) does not satisfy my needs. I am having trouble on utils module. because when I comment out the line from utils.datasets import get_labels
The error is on the next line:
ModuleNotFoundError: No module named 'utils.inference'
The utils model what the code your provided want to import is the part of the oarriaga/face_classification project.
The pip installed utils modul is quite different package, so you should not have installed via pip. Your code try to import moduls from this package, but it obviously has no such moduls. That is why the error messages.
So what you have to do is pip uninstall utils and then if your project directory structure is complete, the above code will import the face_classification package's moduls.
I am just starting with TensorFlow and came across the TensorFlow Object Detection API tutorial. I have followed the installation steps outlined in the first section, created a new conda virtual environment (within Visual Studio 2017) and installed TensorFlow using pip. Also I have installed the packages listed in the other sections.
This are the imports taken from here: Detect Objects Using Your Webcam
import numpy as np
import os
import six.moves.urllib as urllib
import sys
import tarfile
import tensorflow as tf
import zipfile
import cv2
from collections import defaultdict
from io import StringIO
from matplotlib import pyplot as plt
from PIL import Image
from utils import label_map_util
from utils import visualization_utils as vis_util
However it can't find the a package/module called utils. Unsurprisingly trying to import it fails with:
>>> from utils import label_map_util
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
ModuleNotFoundError: No module named 'utils'
So what kind of module is this and where can I get it from?
Add the root directory of Object Detection API ( ...\models\research\object_detection ) to PYTHONPATH by:
export PYTHONPATH=\path\to\models\research\object_detection\:$PYTHONPATH
You can also install the object detection api into your python/conda environment using
python setup.py build
python setup.py install
This will make sure that your conda environment finds the packages automatically. The setup.py file is in the models/research folder.
My imports :
from pydub import AudioSegment
import matplotlib.pyplot as plt
import numpy as np
import wave
import sys
why am i getting that error while i'm clearly not importing tkinter and how to fix it
One of your imported packages requires tkinter as a dependency, so you need to install it.
# if you are using Anaconda
conda install tk
# if you are using Ubuntu
sudo apt-get install python3-tk