Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

ImportError: cannot import name 'parameter_parser' from 'parser' (unknown location)

I am trying to Import Parameter_parser from Parser. but it is showing the error below:

ImportError: cannot import name 'parameter_parser' from 'parser'

In the line below that I also get:

ModuleNotFoundError: No module named 'load_data'

This is my code:

    import matplotlib 
    matplotlib.use('agg') 
    import numpy as np 
    import time 
    import os 
    import torch.utils.data 
    import torch.nn.functional as F 
    import torch.optim as optim 
    import torch.optim.lr_scheduler as lr_scheduler 
    from torch.utils.data import DataLoader 
    from os.path import join as pjoin 
    from parser import parameter_parser 
    from load_data import split_ids, GraphData, collate_batch 
    from models.gcn_modify import GCN_MODIFY 
    from models.gcn_origin import GCN_ORIGIN 
    from models.gat import GAT 
    from models.mgcn import MGCN 
    from sklearn import metrics`
like image 520
Drashti Bhatt Avatar asked Jun 04 '26 14:06

Drashti Bhatt


1 Answers

When I try the same thing in my python console I get this:

>>>  from parser import parameter_parser


File "<stdin>", line 1
    from parser import parameter_parser
    ^
IndentationError: unexpected indent
>>> from parser import parameter_parser
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
ImportError: cannot import name parameter_parser

Is this the same problem for you? This is because you don't have the module installed via pip (pip install PACKAGE_NAME) or whatever you use to install your packages. Another idea is that you have set up a virtual env, installed it there and did not activate it.

At any case although I didn't downvote your answer (I think there are no wrong questions!) I assume the person that did was not able to find the additional information to help you solve your problem. for next time try adding what OS you are using, what package is causing the problem and what solutions have you already tried (did you find other answers on stackoverflow? did you google the problem? did you try importing the package by itself in the console?).

like image 96
elad silver Avatar answered Jun 07 '26 23:06

elad silver