name 'sys' is not defined

Pieter van Oostrum pieter-l at vanoostrum.org
Mon Dec 30 10:04:46 EST 2019


safiq713 at gmail.com writes:

> Deal all,
> Could you please help me how can I avoid this problem
> my Jupyter Notebook code was 
> help pls
>
>
>
> # init a treemix analysis object with some param arguments
> tmx = ipa.treemix(
>     data=data,
>     imap=imap,
>     minmap=minmap,
>     seed=123456,
>     root="Petronia_petronia",
>     m=2,
> )
>
> error
>
> NameError                                 Traceback (most recent call last)
> <ipython-input-8-d80ffd5719d7> in <module>
>       6     seed=123456,
>       7     root="Petronia_petronia",
> ----> 8     m=2,
>       9 )
>
> ~/opt/miniconda3/envs/py3/lib/python3.6/site-packages/ipyrad/analysis/treemix.py in __init__(self, data, name, workdir, imap, minmap, seed, quiet, raise_root_error, binary, *args, **kwargs)
>     118 
>     119         # others
> --> 120         self.binary = os.path.join(sys.prefix, "bin", "treemix")
>     121         self.binary = (binary if binary else self.binary)
>     122         self.raise_root_error = raise_root_error
>
> NameError: name 'sys' is not defined

As the name sys is used in the imported module, that module has to import sys.
Importing it in the calling code doesn't help.
So I would say this is a bug in the module.

You should report the bug to its author. In the meantime you can correct your own copy at
~/opt/miniconda3/envs/py3/lib/python3.6/site-packages/ipyrad/analysis/treemix.py
by adding
import sys
for example around line 10

-- 
Pieter van Oostrum
www: http://pieter.vanoostrum.org/
PGP key: [8DAE142BE17999C4]


More information about the Python-list mailing list