AS-GCN icon indicating copy to clipboard operation
AS-GCN copied to clipboard

import_class not found

Open jingong opened this issue 6 years ago • 22 comments

jingong avatar Jul 01 '19 07:07 jingong

It is present in the Torchlight folder. Have you built torchlight from setup.py? If yes, then, you may need to change the relative import here:

from torchlight import import_class

Anirudh257 avatar Jul 02 '19 06:07 Anirudh257

I've run this code "python setup.py install", but I still can't import it.

tcxia avatar Sep 09 '19 05:09 tcxia

@MarsTT, you will have to check the paths for the import_class function within torchlight. I think that import_class is in torchlight/io.py. https://github.com/limaosen0/AS-GCN/blob/ab6951c3e6fc1b22bb4a0dc87a33cca228aa69fe/torchlight/torchlight/io.py#L181. So, you may need to change the line to

from torchlight.io import import_class

You can repeat these steps for the other functions in the code.

Anirudh257 avatar Sep 09 '19 06:09 Anirudh257

我也有同样的问题 请问您解决了吗

dangao250 avatar Nov 14 '19 13:11 dangao250

I've run this code "python setup.py install", but I still can't import it.

Have you solved it?

dangao250 avatar Nov 14 '19 13:11 dangao250

@dangao250 You can follow the steps outlined by me. It worked.

Anirudh257 avatar Nov 14 '19 19:11 Anirudh257

You can follow the steps outlined by me. It worked.

I did what you did, but I still made a mistake image

dangao250 avatar Nov 15 '19 01:11 dangao250

  1. In torchlight directory, you will another torchlight directory which has 3 files:
  1. gpu.py
  2. init.py
  3. io.py.

Copy these to the outer torchlight directory like below image

  1. In all your files, you have to make changes in the torchlight import code.
from torchlight.io import import_class

should be the correct code.

For example, in processor/io.py file, the import line changes to:

image

Anirudh257 avatar Nov 15 '19 01:11 Anirudh257

It is present in the Torchlight folder. Have you built torchlight from setup.py? If yes, then, you may need to change the relative import here:

from torchlight import import_class

image How to solve this error?

dangao250 avatar Nov 15 '19 02:11 dangao250

  1. In torchlight directory, you will another torchlight directory which has 3 files:

  2. gpu.py

  3. init.py

  4. io.py.

Copy these to the outer torchlight directory like below image

  1. In all your files, you have to make changes in the torchlight import code.
from torchlight.io import import_class

should be the correct code.

For example, in processor/io.py file, the import line changes to:

image

image How can you solve this problem?

dangao250 avatar Nov 15 '19 03:11 dangao250

image How do you solve this problem?

dangao250 avatar Nov 15 '19 05:11 dangao250

  1. In torchlight directory, you will another torchlight directory which has 3 files:

  2. gpu.py

  3. init.py

  4. io.py.

Copy these to the outer torchlight directory like below image

  1. In all your files, you have to make changes in the torchlight import code.
from torchlight.io import import_class

should be the correct code.

For example, in processor/io.py file, the import line changes to:

image

How do you solve this problem?

dangao250 avatar Nov 15 '19 05:11 dangao250

How do you solve this problem? image

dangao250 avatar Nov 15 '19 05:11 dangao250

There is no IO class in torchlight. It is present in io.py file in torchlight folder. For this and other similar issues, you will have to read the 3 files present in the torchlight folder.

Anirudh257 avatar Nov 15 '19 09:11 Anirudh257

I replaced the torchlight/torchlight/__ Init__.py file here with the__Init__.py file under the stgcn project, and then ran setup.py again. This works.

wly1998 avatar Mar 02 '20 13:03 wly1998

I replaced the torchlight/torchlight/__ Init__.py file here with the__Init__.py file under the stgcn project, and then ran setup.py again. This works.

Did you change from torchlight. import import_class to from torchlight.io import import_class? I did what you said but got an error: ModuleNotFoundError: No module named 'processor.demo'

ywang0218 avatar May 08 '20 20:05 ywang0218

@ywang0218 You can comment the line processor.demo

Anirudh257 avatar May 09 '20 09:05 Anirudh257

Surprising! It worked. Thank you very much!

Thomas-yx avatar Jul 12 '20 05:07 Thomas-yx

Surprising! It worked. Thank you very much!

Hello, may I ask you is how to solve ‘ImportError: can not import name 'import_class'’.

a726 avatar Aug 10 '20 04:08 a726

Hi,it's so easy.You can use this sentence 'from torchlight.io import_class' instead of the original sentence. Because the function of 'import_class' is in the io.py rather than the file of torchlight.I hope my answer can help you.

------------------ 原始邮件 ------------------ 发件人: "limaosen0/AS-GCN" <[email protected]>; 发送时间: 2020年8月10日(星期一) 中午12:01 收件人: "limaosen0/AS-GCN"<[email protected]>; 抄送: "苦海两颗糖"<[email protected]>;"Comment"<[email protected]>; 主题: Re: [limaosen0/AS-GCN] import_class not found (#4)

Surprising! It worked. Thank you very much!

Hello, may I ask you is how to solve ‘ImportError: can not import name 'import_class'’.

— You are receiving this because you commented. Reply to this email directly, view it on GitHub, or unsubscribe.

Thomas-yx avatar Aug 10 '20 06:08 Thomas-yx

OK,thanks.发自我的华为手机-------- 原始邮件 --------发件人: Thomas_y [email protected]日期: 2020年8月10日周一 下午2:24收件人: limaosen0/AS-GCN [email protected]抄送: Xiaoyuan Zhang [email protected], Comment [email protected]主 题: Re: [limaosen0/AS-GCN] import_class not found (#4)

Hi,it's so easy.You can use this sentence 'from torchlight.io import_class' instead of the original sentence. Because the function of 'import_class' is in the io.py

rather than the file of torchlight.I hope my answer can help you.

------------------ 原始邮件 ------------------

发件人: "limaosen0/AS-GCN" <[email protected]>;

发送时间: 2020年8月10日(星期一) 中午12:01

收件人: "limaosen0/AS-GCN"<[email protected]>;

抄送: "苦海两颗糖"<[email protected]>;"Comment"<[email protected]>;

主题: Re: [limaosen0/AS-GCN] import_class not found (#4)

Surprising! It worked. Thank you very much!

Hello, may I ask you is how to solve ‘ImportError: can not import name 'import_class'’.

You are receiving this because you commented.

Reply to this email directly, view it on GitHub, or unsubscribe.

—You are receiving this because you commented.Reply to this email directly, view it on GitHub, or unsubscribe.

a726 avatar Aug 10 '20 07:08 a726

I've run this code "python setup.py install", but I still can't import it.

you need to add the outer torchlight folder to the system path, just run the code below:

import sys sys.path.insert(0, '/content/drive/MyDrive/ST-GCN/torchlight')

that will solve this problem but it probably add the isue of no mudule name torchlight in processor.process.py which you need to modify this file and add

import torchlight.torchlight as torchlight instead of import torchlight

babaee74 avatar May 15 '22 22:05 babaee74