Troubleshooting

Diagnose pynescript install, parse, lint, evaluation, LSP, data providers, and Pro API failures with concrete checks.

This page

Troubleshooting

Abstract

Failures cluster by layer: environment, parse, lint, evaluation, data I/O, LSP, HTTP. Work top-down: confirm the binary/module, then a minimal script, then full strategy complexity. This page is a runbook; deep protocol and runtime docs are linked per section.

Conceptual model

Diagram

Rendering…

Interface surface (diagnostic commands)

python -c "import pynescript; from pynescript import __about__; print(__about__.__version__)"
python -c "from pynescript.ast import parse, unparse; print(unparse(parse('//@version=6\nindicator(\"t\")\nplot(close)\n')))"
pyne --version
pyne lint - <<< $'//@version=6\nindicator("t")\nplot(close)\n'
python -c "import pygls"  # LSP extra
python -c "import ccxt"   # data extra
curl -s http://127.0.0.1:5002/ | head

Internals (where errors originate)

LayerPath
CLIsrc/pynescript/__main__.py
Parsesrc/pynescript/ast/helper.py, ANTLR error listener
Lintsrc/pynescript/ast/linter.py
Evalsrc/pynescript/ast/evaluator/, src/pynescript/runtime/
Datasrc/pynescript/util/data.py
LSPsrc/pynescript/langserver/
HTTPbackend/app.py, backend/middleware/schemas.py

Invariants & edge cases

  • Minimal green script for isolation:
//@version=6
indicator("t")
plot(close)
  • Encoding must be UTF-8 unless you pass --encoding.
  • Pine v4 and earlier trigger linter deprecation (W002); parser support may still differ by construct.
  • Recursion limit is raised only during parse; extreme generated scripts can still fail.

Worked examples (by symptom)

1. pyne / pynescript: command not found

which python
python -m pynescript --help
# If module works but script does not:
python -m pip show hoox-pyne
ls "$(python -c 'import sysconfig; print(sysconfig.get_path("scripts"))')"

Fix: activate the venv used for install; reinstall pip install hoox-pyne (import package is still pynescript). Do not pip show pynescript — that is a different PyPI project.

2. ModuleNotFoundError: pynescript

Wrong interpreter (IDE using system Python). Point the IDE at the venv; reinstall editable from repo root: pip install -e ..

3. Parse / SyntaxError

pyne parse-and-dump broken.pine

Checks:

  • //@version=6 present (v5 still accepted)
  • Balanced parentheses / indentation (Pine uses line structure)
  • Multiline strings / v6 features need a package version that includes them
  • Binary/null bytes in file

Reduce to a minimal repro; if TV accepts it and PYNE does not, consult missing features and file a grammar issue.

4. Round-trip looks “wrong”

unparse normalizes formatting. Compare dumps:

pyne parse-and-dump a.pine > /tmp/a.ast
pyne parse-and-unparse a.pine | pyne parse-and-dump /dev/stdin
# stdin may not work for parse-and-dump (file path required) — use a temp file:
pyne parse-and-unparse a.pine --output-file /tmp/a2.pine
pyne parse-and-dump /tmp/a2.pine > /tmp/a2.ast
diff -u /tmp/a.ast /tmp/a2.ast

Structural diff empty ⇒ cosmetic only.

5. Lint noise / CI red

CodeAction
E001Fix syntax first
W001Add //@version=6
W002Upgrade version pragma
C001C004Style; use --fail-on errors if style should not gate CI
pyne lint script.pine --fail-on errors

6. literal_eval fails

  • Use mode="eval"-compatible expressions, not full strategy() scripts
  • Pass series as Python lists inside the expression or via context
  • Missing builtin → incomplete implementation

Escalate to Runtime.run for multi-bar scripts.

7. Runtime / /run execution error

curl -s -X POST http://127.0.0.1:5002/run -H 'Content-Type: application/json' -d '{"script":"//@version=6\nindicator(\"t\")\nplot(close)","data":[{"time":1,"open":1,"high":1,"low":1,"close":1,"volume":1}]}'

If minimal works but strategy fails: remove request.*, drawings, then strategy entries until isolated. Check mode; try "interpret". Library Runtime.run defaults to interpret; POST /run defaults to auto; pyne run is compile-only synthetic smoke — they will not match each other unless you set mode explicitly. See modes.

8. Schema validation errors

UNKNOWN_FIELDS means you sent a key not in the schema — remove it. Do not rely on servers ignoring extras.

9. CORS from AXIS / browser

export ALLOWED_ORIGINS="http://localhost:8081,http://127.0.0.1:8081"

Restart Flask after changing env.

10. LSP will not start

pip install "hoox-pyne[lsp]"
python -c "import pygls, lsprotocol"
command -v pyne-lsp   # alias: pynescript-lsp
# Run with editor logging enabled; check stderr for import traces

Ensure the editor’s command matches the venv. For Neovim, confirm filetypes include your buffer’s filetype.

11. Data provider failures

ProviderChecklist
mockShould always work offline
yahooNetwork; symbol format
alphavantageAPI key; demo limits
ccxtpip install "hoox-pyne[data]"; exchange id; symbol BTC/USDT
pyne data AAPL --provider mock

12. Version / parity confusion

PYNE is independent of TradingView®. Behavioral gaps are expected for edge builtins, broker emulators, and UI-only calls. Use compatibility and implementation status.

Failure modes (quick matrix)

SymptomLayerFirst check
Command not foundenvpython -m pynescript
Import error pyglsextra[lsp]
Import error ccxtextra[data]
SyntaxErrorparseminimal script + version
Lint CI faillint--fail-on level
Empty plotsevalplot() present; enough bars
pyne runRuntime.runmodesCLI is compile-only synthetic; library default is interpret
UNKNOWN_FIELDS + timeout_secondsHTTPfield is valid on /run and /run/batch (0.3.11+); other extra keys still 400
400 UNKNOWN_FIELDSHTTPschema
403 create_keyHTTPADMIN_TOKEN
413HTTPbody size
Squiggles missingLSPdiagnostics enabled + filetype
Numerical driftevalwarmup / parity docs

See also