0

I read book, I try practice these code snippet

>>> from lis import parse
>>> parse('1.5')
1.5

Then I follow guide at https://github.com/adamhaney/lispy#getting-started . My PC is Windows 11 Pro x64.

C:\Users\donhu>python -V
Python 3.10.4

C:\Users\donhu>pip -V
pip 22.0.4 from C:\Program Files\Python310\lib\site-packages\pip (python 3.10)

C:\Users\donhu>pip install lispy
Defaulting to user installation because normal site-packages is not writeable
ERROR: Could not find a version that satisfies the requirement lispy (from versions: none)
ERROR: No matching distribution found for lispy

C:\Users\donhu>

enter image description here

I also try install with Anaconda, but not success.

enter image description here

How to fix?

Vy Do
  • 46,709
  • 59
  • 215
  • 313

2 Answers2

1

lispy is not a library in pip downloadable library. Instead, install lispy from the github repo. Here is a Link to post explaining how install directly from github repo

  • Please revise your answer. You said near true. https://user-images.githubusercontent.com/1328316/165529265-1f2c9611-67a3-49a3-b147-fa441c8daa33.png – Vy Do Apr 27 '22 at 13:27
  • I see http://norvig.com/lispy.html and http://norvig.com/lis.py Please help me a working solution. This is code snippet I need practice https://github1s.com/donhuvy/example-code-2e/blob/HEAD/02-array-seq/lispy/py3.9/examples_test.py – Vy Do Apr 27 '22 at 13:29
  • @DaoMinhThu this is not version to install - but simply download `lis.py` and put in folder in which you run your code. – furas Apr 27 '22 at 18:44
  • @DaoMinhThu I can install this [lispy](https://github.com/adamhaney/lispy) using `pip install git+https://github.com/adamhaney/lispy` (with `git+` before `https`) but this install program `lispy` which I can run in console and it waits for lisp commands (interactive mode). Eventually I can `import lispy` but this is not original `lis.py` but modification and it doesn't have `parse()` but `lispy.runtime.parse()` – furas Apr 27 '22 at 18:50
1

It seems Norvig's lispy is not module for installing but you have to download lis.py and put in folder with your code - or you would have to manually put it in folder with other modules.


As for github repo adamhaney/lispy: on Linux I can install it using git+ before https

pip install git+https://github.com/adamhaney/lispy 

But this is not original lis.py but some modification and it needs

import lispy

parsed = lispy.runtime.parse('(define pi 3.141592653589793)')
result = lispy.runtime.eval(parsed)

parsed = lispy.runtime.parse('(define r 10)')
result = lispy.runtime.eval(parsed)

parsed = lispy.runtime.parse('(* pi (* r r))')
result = lispy.runtime.eval(parsed)

print(result)

or more useful

import lispy

def cmd(text):
    parsed = lispy.runtime.parse(text)
    result = lispy.runtime.eval(parsed)
    if result:
        print(result)

# --- main ---

cmd('(define pi 3.141592653589793)')
cmd('(define r 10)')
cmd('(* pi (* r r))')

or using interactive mode which displays prompt lispy>

import lispy

lispy.runtime.Runtime().repl()

BTW: repo adamhaney/lispy is 10 years old (last update on 6 Jul 2013) and maybe this is problem. Maybe this lispy was removed from pypi.org and now you can't install it with pip


EDIT:

See also main page norvig.com - there is link to "NEW" List of Jupyter/Ipython notebooks with the newest materials (even from 2022)

furas
  • 134,197
  • 12
  • 106
  • 148