(Closed) Value Error: Attempted relative import in non-package

5 months ago by
I am trying to install a Fenics code from a repo that calls 

from utils import * 
which import modules by following lines in code

import os
import dolfin as df
from ..numpy_mpi import *
from ..adjoint_contraction_args import logger

and results in following error:-
Value error : Attempted relative import in  non-package

I have numpy_mpi import* in the same folder where utils.py have been kept. Whats wrong am i doing thats causing this error ?

Community: FEniCS Project

This post is closed by moderator and no new answer/comment may be added.

Hi ovais, this is not very related to FEniCS. Please, post only question tightly related to FEniCS. We do not provide general python consulting here.

written 5 months ago by Michal Habera  

1 Answer

5 months ago by
just a hit and trail solved the issue once i placed the files numpy_mpi.py and adjoint_contraction_args.py in the same folder as the python file which was calling init. After that i removed dots i.e. instead of  ..numpy_mpi import* , i wrote from numpy_mpi import* . These changes have apparently solved the issue as i am not getting the same error now.

This post (here) helped me figure out this solution .
Please login to add an answer/comment or follow this question.
The thread is closed. No new answer/comment may be added.

Similar posts:
Search »