How to fix "cannot import name '***'" in python

how to fix anything
how to fix phone
how to fix stuff
how to fix everything book
how to fix a zipper
how to fix broken things
how to fix things around the house
how to fix everything lyrics

I'm using python3.6 and I'm having this error:

"ImportError: cannot import name 'video_transforms'".

I'm trying to import using:

from . import video_transforms as transforms

This video_transform.py file is this file:

https://github.com/cypw/PyTorch-MFNet/blob/master/data/video_transforms.py

And he is importing this file:

https://github.com/cypw/PyTorch-MFNet/blob/master/data/image_transforms.py

Once I had this problem inside my program, I decided to do something simpler, I went into python shell and just did:

from . import video_transforms as transforms

Got the same error.

I read a lot about this error, and I found most of the people got this because of circular problems, but here I can't see that this si the case.

I'll be happy for your help, Thanks!

Replace this:

from . import video_transforms as transforms

With this:

from .import video_transforms as transforms

How to Fix ANYTHING, Timestamps 00:01 Slime cleaning trick 02:29 Coca-cola rust removal 02:55 Wall repair trick 03 Duration: 13:56 Posted: Apr 21, 2020 Here's how: 1. Navigate to the Windows 10 Advanced Startup Options menu. On many laptops, hitting F11 as soon as you power on will 2. Click Startup Repair.

You can try sys.path.append('path/to/file') before the import

How To Repair Almost Everything, Here's how to fix it. Text by Jen Rose Smith and illustrations by Max Pepper, CNN . Updated 4:07 AM ET, Thu August 20, 2020. Mouth breathing through the night� iFixit is a global community of people helping each other repair things. Let's fix the world, one device at a time. Troubleshoot with experts in the Answers forum—and build your own how-to guides to share with the world.

I got this headache many times. The dot . in import (or from) lines says that this file is trying to import something from other files when we treat all the files wrapped inside a so-called package.

I just clone Pytorch-MFNet from Github to reproduce your error. The code itself is nothing wrong and runnable.

Two ways for you to test the code in ipython or Python Shell (I recommend using ipython since we can use Tab for text completion):

Treat all the files in data as the modules of package data.

So, you open your python shell outside data directory.

# cd ./Pytorch-MFNet  ---> Now we are in Pytorch-MFNet directory

# import anything you want in data package.
# any lines below work properly, take one to test

from data import video_transforms
from data.video_transforms import *
import data.video_transforms as video_transforms

# test
to_tensor = video_transforms.ToTensor()
Treat all the files in data as normal modules

So, you can go inside the data directory and import anything from files. However, you must remove . in video_transforms.py as follows:

# in video_transforms.py

from image_transforms import Compose, \
                              Transform, \
                              Normalize, \
                              Resize, \
                              RandomScale, \
                              CenterCrop, \
                              RandomCrop, \
                              RandomHorizontalFlip, \
                              RandomRGB, \
                              RandomHLS

Now go to data directory and enjoy your checking with the following code in python shell

# cd ./Pytorch-MFNet/data

from video_transforms import *
from video_transforms import ToTensor

# any above code should work!

Hope this helps.

Mouth breathing might be ruining your sleep. Here's how to fix it, How to Fix (Just About) Everything: More Than 550 Step-by-Step Instructions for Everything from Fixing a Faucet to Removing Mystery Stains to Curing a� Easy Fix solutions have been discontinued. Instead, you can upgrade to Windows 10 and get troubleshooters that are built right in. To get Windows 10, see Windows 10 Home. Need more info on Windows 10? See Upgrade to Windows 10: FAQ. Windows 10. Windows 10 uses troubleshooters to help you solve problems with your PC. To run a troubleshooter:

The . indicates, that you want to load from a package the module is in (see here)

Effectively you'll have to import the functions into the package namespace. You want the following file layout:

app.py
data/
  __init__.py
  video_transforms.py
  image_transforms.py

In your /data/__init__.py you can then do an relative import

from . import video_transforms

However, this assumes that your program lives in app.py There you can do something like

from data import video_transforms

How to Fix (Just About) Everything: More Than 550 Step-by-Step , New Fix-It-Yourself Manual: How to Repair, Clean, and Maintain Anything and Everything In and Around Your Home [Reader's Digest] on Amazon.com. *FREE* � How to Fix the Most Annoying Things in Windows 10 Stop Auto Reboots. Windows 10 updates are regular and seemingly never-ending, and pretty much out of the user's control Prevent Sticky Keys. If you hit the Shift key five times in a row in Windows, you activate Sticky Keys, a Windows Calm the

New Fix-It-Yourself Manual: How to Repair, Clean, and Maintain , Learn how to fix your broken appliance yourself, no repairman needed. Select the appliance that is giving you trouble and you'll find information on the common � Here are 6 steps to fix it yourself. Don't get frustrated and give up on a slow PC, take a few minutes to troubleshoot and remedy it. Jason Cipriani. May 7, 2020 3:00 a.m. PT.

How To Fix A Broken Appliance, This educator's guide provides articles, videos & other resources to aid in teaching about tools, common home repair projects and vocabulary to students. Minor holes and tears in window screening are also common problems. Use screen repair tools like glue, an awl, metal thread and pre-manufactured patches to patch a window screen in three easy steps. This guide will teach you how to replace and repair your window screens.

How to Fix It Yourself, Klayman explains, “A key principle of future-focused feedback is to avoid talking about why things went wrong in the past. This runs counter to� To repair the corrupted files manually, view details of the System File Checker process to find the corrupted file, and then manually replace the corrupted file with a known good copy of the file. More Information

Comments
  • Can you elaborate on this? I can't find anything in the docs about that space being significant...
  • Strange because for me this works. sys.path.append("C:/Users/tibszucs/Desktop/") import video_transforms
  • I have main.py and those two files in the save directory. so I created an init.py file with the line you said. and than I tried to import using: "import .video_transforms as video_transforms" this gave me a syntax error. And When I import using: "from .import video_transforms as transforms" Still getting the same error... Did I understand your solution correctly?
  • @albert1905 It must be an init.py file, I edited the answer to make it more clear