Skip to content
This repository has been archived by the owner on Apr 9, 2024. It is now read-only.

Node error saving chart as PDF: Cannot find module 'infer-owner' #119

Closed
pankajb64 opened this issue Feb 27, 2023 · 1 comment
Closed

Node error saving chart as PDF: Cannot find module 'infer-owner' #119

pankajb64 opened this issue Feb 27, 2023 · 1 comment

Comments

@pankajb64
Copy link

I see there are previous issues logged as #13 and #115 , but my error seems different so i'm creating a separate issue.

I installed altair saver using conda install -c conda-forge altair_saver. Now, when trying to save a chart as PDF, I get this error, which seems from nodejs.

internal/modules/cjs/loader.js:670
    throw err;
    ^

Error: Cannot find module 'infer-owner'
    at Function.Module._resolveFilename (internal/modules/cjs/loader.js:668:15)
    at Function.Module._load (internal/modules/cjs/loader.js:591:27)
    at Module.require (internal/modules/cjs/loader.js:723:19)
    at require (internal/modules/cjs/helpers.js:14:16)
    at Object.<anonymous> (/Users/ciboguest/misc/ljmu/ljmu_paper_env/lib/node_modules/npm/node_modules/gentle-fs/lib/mkdir.js:4:20)
    at Module._compile (internal/modules/cjs/loader.js:816:30)
    at Object.Module._extensions..js (internal/modules/cjs/loader.js:827:10)
    at Module.load (internal/modules/cjs/loader.js:685:32)
    at Function.Module._load (internal/modules/cjs/loader.js:620:12)
    at Module.require (internal/modules/cjs/loader.js:723:19)

this same error happens if I try to install the package infer-owner using npm install infer-owner, or if I try npm install -g infer-owner

the python error is similar to #115 ,

CalledProcessError                        Traceback (most recent call last)
Input In [16], in <cell line: 1>()
----> 1 altair_saver.save(chart_5nn_cc, 'fig.pdf')

File ~/misc/ljmu/ljmu_paper_env/lib/python3.9/site-packages/altair_saver/_core.py:169, in save(chart, fp, fmt, mode, embed_options, method, suppress_data_warning, **kwargs)
    166 if embed_options is None:
    167     embed_options = alt.renderers.options.get("embed_options", None)
--> 169 Saver = _select_saver(method, mode=mode, fmt=fmt, fp=fp)
    170 saver = Saver(spec, mode=mode, embed_options=embed_options, **kwargs)
    172 return saver.save(fp=fp, fmt=fmt)

File ~/misc/ljmu/ljmu_paper_env/lib/python3.9/site-packages/altair_saver/_core.py:67, in _select_saver(method, mode, fmt, fp)
     65     fmt = extract_format(fp)
     66 for s in _SAVER_METHODS.values():
---> 67     if s.enabled() and fmt in s.valid_formats[mode]:
     68         return s
     69 raise ValueError(f"No enabled saver found that supports format={fmt!r}")

File ~/misc/ljmu/ljmu_paper_env/lib/python3.9/site-packages/altair_saver/savers/_node.py:103, in NodeSaver.enabled(cls)
    100 @classmethod
    101 def enabled(cls) -> bool:
    102     try:
--> 103         return bool(exec_path("vl2vg") and exec_path("vg2png"))
    104     except ExecutableNotFound:
    105         return False

File ~/misc/ljmu/ljmu_paper_env/lib/python3.9/site-packages/altair_saver/savers/_node.py:29, in exec_path(name)
     27 @functools.lru_cache(16)
     28 def exec_path(name: str) -> str:
---> 29     for path in [None, npm_bin(global_=True), npm_bin(global_=False)]:
     30         exc = shutil.which(name, path=path)
     31         if exc:

File ~/misc/ljmu/ljmu_paper_env/lib/python3.9/site-packages/altair_saver/savers/_node.py:24, in npm_bin(global_)
     22 if global_:
     23     cmd.append("--global")
---> 24 return check_output_with_stderr(cmd).decode().strip()

File ~/misc/ljmu/ljmu_paper_env/lib/python3.9/site-packages/altair_saver/_utils.py:198, in check_output_with_stderr(cmd, shell, input, stderr_filter)
    176 """Run a command in a subprocess, printing stderr to sys.stderr.
    177 
    178 This function exists because normally, stderr from subprocess in the notebook
   (...)
    195 subprocess.CalledProcessError : if the called process returns a non-zero exit code.
    196 """
    197 try:
--> 198     ps = subprocess.run(
    199         cmd,
    200         shell=shell,
    201         input=input,
    202         check=True,
    203         stdout=subprocess.PIPE,
    204         stderr=subprocess.PIPE,
    205     )
    206 except subprocess.CalledProcessError as err:
    207     stderr = err.stderr

File ~/misc/ljmu/ljmu_paper_env/lib/python3.9/subprocess.py:528, in run(input, capture_output, timeout, check, *popenargs, **kwargs)
    526     retcode = process.poll()
    527     if check and retcode:
--> 528         raise CalledProcessError(retcode, process.args,
    529                                  output=stdout, stderr=stderr)
    530 return CompletedProcess(process.args, retcode, stdout, stderr)

CalledProcessError: Command '['/Users/ciboguest/misc/ljmu/ljmu_paper_env/bin/npm', 'bin', '--global']' returned non-zero exit status 1.

Any help would be appreciated.

@pankajb64 pankajb64 changed the title Alitar error when saving chart as PDF Node error saving chart as PDF: Cannot find module 'infer-owner' Feb 27, 2023
@pankajb64
Copy link
Author

confirming that this issue is the same as #113, and this hotfix works.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant