graphvite icon indicating copy to clipboard operation
graphvite copied to clipboard

Raise KeyError: 'PREFIX' when import

Open RaistlinTAO opened this issue 2 years ago • 2 comments

The program just stop with 'raise KeyError(key) from None' error right after 'import graphvite as gv', with no other code.

Environment

Python: 3.8 Conda: Latest CentOS

Error Message

Traceback (most recent call last):
  File "DGI_matrix.py", line 19, in <module>
    import graphvite as gv
  File "/apphome/algorithm/anaconda3/envs/xnf/lib/python3.8/site-packages/graphvite/__init__.py", line 30, in <module>
    os.path.realpath(os.path.join(os.environ["PREFIX"], "lib")),
  File "/apphome/algorithm/anaconda3/envs/xnf/lib/python3.8/os.py", line 675, in __getitem__
    raise KeyError(key) from None
KeyError: 'PREFIX'

RaistlinTAO avatar Jun 28 '22 12:06 RaistlinTAO

Simply removing the os.path.realpath(os.path.join(os.environ["PREFIX"], "lib")), line solved the problem for me

elya5 avatar Jul 05 '22 13:07 elya5

Simply removing the os.path.realpath(os.path.join(os.environ["PREFIX"], "lib")), line solved the problem for me

Best-practice-wise, I d like to stay away from touching the source code of dependencies, since we have other members working on this.

RaistlinTAO avatar Jul 13 '22 15:07 RaistlinTAO

Same with you, have you deal with this problem?

import graphvite Traceback (most recent call last): File "", line 1, in File "/home/lyj/anaconda3/envs/graphvite3/lib/python3.8/site-packages/graphvite/init.py", line 30, in os.path.realpath(os.path.join(os.environ["PREFIX"], "lib")), File "/home/lyj/anaconda3/envs/graphvite3/lib/python3.8/os.py", line 675, in getitem raise KeyError(key) from None KeyError: 'PREFIX'

YijianLiu avatar Oct 07 '22 08:10 YijianLiu

Bevor I imported graphvite I used

os.environ["CONDA_PREFIX"] = sys.base_prefix
os.environ["PREFIX"]= sys.base_prefix

p-dre avatar Jan 27 '23 09:01 p-dre

Did you know the solution for this problem?

DaliaDawod avatar Apr 10 '23 19:04 DaliaDawod

Did you know the solution for this problem?

Define os.environ["PREFIX"] by yourself should fix this.

RaistlinTAO avatar Apr 12 '23 12:04 RaistlinTAO