ModuleNotFoundError for .vision and .utils , download_url, VisionDataset - google-colaboratory

I am trying to create a custom dataset in google colab, but imports give me errors.
from PIL import Image
from six.moves import zip
import os
from .vision import VisionDataset ------------------------(1)
from .utils import download_url, check_integrity --------------(2)
class datasetName(VisionDataset):
...
(1) error :
ModuleNotFoundError: No module named 'main.vision'; 'main' is
not a package
(2) error :
ModuleNotFoundError: No module named 'main.utils'; 'main' is
not a package
I have tried to add from torchvision import utils but it does not solve the error.
If I change to from torch.utils import download_url, check_integrity
then the error becomes:
ImportError: cannot import name 'download_url'

Please try the following import lines.
from torchvision.datasets.vision import VisionDataset
from torchvision.datasets.utils import download_url, check_integrity
Hope it helps!

Related

ModuleNotFoundError: No module name ''loadingscripts'. I have loading_scipts in an import command. How do I resolve this?

from loading_scripts.utils.loading_strategies.append_loading_strategy import AppendLoadingStrategy
#from loading_scripts.utils.loading_strategies.append_loading_strategy import AppendLoadingStrategy

Facebook prophet cannot import name 'lag_baomer' from 'convertdate.holidays'

I found issue when import fbprophet
ImportError: cannot import name 'lag_baomer' from 'convertdate.holidays'

ImportError: cnot import - 'kneeLocator' from 'kneed' (/usr/local/lib/python3.7/dist-packages/kneed/__init__.py)

I install(pip install kneed) the Kneed, but when I re-run the Import again but it keeps showing me the error(Colad)
pip install kneed.
2.from kneed import kneeLocator(Error).
ImportError: cannot import name 'kneeLocator' from 'kneed' (/usr/local/lib/python3.7/dist-packages/kneed/init.py)

Can't import QSound from PyQt5.QtGui

I'm trying to use QSound for my application, but whenever I try to import it I get the error:
ImportError: cannot import name 'QSound'
Using python console with no success, as:
from PyQt5 import QtGui
from PyQt5.QtGui import QSound
I tried to import it from PyQt5.QtCore and PyQt5 Same error.
As stated by #S. Nick , the correct import was
from PyQt5.QtMultimedia import QSound

Creating executable with Py2exe and matplotlib errors

I have been searching this forum and many others and cannot seem to get a good method of creating an executable. I have tried several different methods (py2exe, pyinstaller and cx_freeze) and all seem to give me some kind of error.
When i tried pyinstaller, I received the error that "no _imaging C module is installed". Everything I search says that it has to do with PIL, but my code is not using PIL.
When I tried py2exe, I keep receiving the following error:
File "Scout_Tool.py", line 18, in <module>
File "matplotlib\pyplot.pyc", line 95, in <module>
File "matplotlib\backends\__init__.pyc", line 25, in pylab_setup
ImportError: No module named backend_qt4agg
I am at a loss of what to do. My code contains the following imports:
import os
import csv
import wx
import time
import math
from matplotlib.backends.backend_wx import FigureCanvasWx as FigureCanvas
from matplotlib.backends.backend_wx import NavigationToolbar2Wx
from matplotlib.pyplot import figure,show
from mpl_toolkits.basemap import Basemap
from matplotlib.figure import Figure
import matplotlib.pyplot as plt
from numpy.random import rand
from datetime import datetime
import wx.calendar as cal
import numpy as npy
from pylab import *
import numpy as np
import matplotlib
import adodbapi
import sqlparse
import pylab
import annote_new
import cPickle as pickle
Does anyone have any suggestions on how to do a build of the executable using py2exe? What i have tried...
from distutils.core import setup
import py2exe
import matplotlib
setup(
windows=[{'script': r'Scout_Tool.py'}],
data_files=matplotlib.get_py2exe_datafiles(),
options={
r'py2exe': {
r'includes': r'ElementConfig',
r'includes': r'ColorConv',
r'includes': r'Tkinter',
r'includes': r're',
r'includes': r'math',
r'includes': r'sys',
r'includes': r'matplotlib',
r'includes': r'mpl_toolkits',
r'includes': r'matplotlib.backends.backend_wx',
r'dll_excludes': [r'MSVCP90.dll'],
}
},
)
Thanks for any help!
I am not fully sure this will fix your problem, but you should start by correcting that faulty options dictionary entry. In python, when you define a dictionary with the same key over and over, you are only going to get the last value. A key can only exist once:
options={
r'py2exe': {
r'includes': r'ElementConfig',
...
r'includes': r'mpl_toolkits',
r'includes': r'matplotlib.backends.backend_wx',
...
}
}
print options
#{'py2exe': {'includes': 'matplotlib.backends.backend_wx'}}
I suspect the result of this usage is py2exe not really finding any of your intended includes. includes should be a list:
options={
'py2exe':{
'includes': [
'ElementConfig',
'ColorConv',
'Tkinter',
're',
'math',
'sys',
'matplotlib',
'mpl_toolkits',
'matplotlib.backends.backend_wx'
],
'dll_excludes': ['MSVCP90.dll'],
}
},
If after this, it still complains about the backend missing, you can add another explicit entry:
'includes': [
...
'matplotlib.backends.backend_qt4agg'
],