bendudson / py4cl

Call python from Common Lisp

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

It seems doesn't work under WINDOWS system

cl-03 opened this issue · comments

commented

win10+emacs+slime+sbcl

CL-USER> (ql:quickload :py4cl/tests)
To load "py4cl/tests":
  Load 1 ASDF system:
    py4cl/tests
; Loading "py4cl/tests"

; file: C:/Users/chuangxiu.chen/quicklisp/dists/quicklisp/software/py4cl-20200925-git/tests/tests.lisp
; in: PY4CL:IMPORT-MODULE "math"
;     (PY4CL:IMPORT-MODULE "math" :RELOAD T)
; 
; caught ERROR:
;   (during macroexpansion of (PY4CL:IMPORT-MODULE "math" ...))
;   end of file on #<SB-SYS:FD-STREAM for "descriptor 848" {100D009453}>
[package py4cl/tests].....................

windows system has installed python.Use Anaconda:

(base) PS C:\Users\chuangxiu.chen> python
Python 3.8.5 (default, Sep  3 2020, 21:29:08) [MSC v.1916 64 bit (AMD64)] :: Anaconda, Inc. on win32
Type "help", "copyright", "credits" or "license" for more information.
Failed calling sys.__interactivehook__
Traceback (most recent call last):
  File "C:\ProgramData\Anaconda3\lib\site.py", line 440, in register_readline
    readline.read_history_file(history)
  File "C:\ProgramData\Anaconda3\lib\site-packages\pyreadline\rlmain.py", line 165, in read_history_file
    self.mode._history.read_history_file(filename)
  File "C:\ProgramData\Anaconda3\lib\site-packages\pyreadline\lineeditor\history.py", line 82, in read_history_file
    for line in open(filename, 'r'):
UnicodeDecodeError: 'gbk' codec can't decode byte 0xa2 in position 106: illegal multibyte sequence
>>>

This looks like a python installation problem, rather than something specific to py4cl. If you get errors by just running "python" then something with the install is going wrong. Google finds some similar errors e.g
zalando/expan#143
https://stackoverflow.com/questions/52049887/anaconda-unicode-error-on-command-line-startup-on-windows

commented

But python program works well.
Under cmd shell:

C:\Users\chuangxiu.chen>python
Python 3.6.4 (v3.6.4:d48eceb, Dec 19 2017, 06:54:40) [MSC v.1900 64 bit (AMD64)] on win32
Type "help", "copyright", "credits" or "license" for more information.
>>>

Maybe should change the codes using the package EXTERNAL-PROGRAM to running the external program Python.

CL-USER> (external-program:run "python" nil :output *standard-output*)
Python 2.7.14 (default, Sep 18 2017, 09:17:44)  [GCC 7.2.0 64 bit (AMD64)] on win32

Type "help", "copyright", "credits" or "license" for more information.

>>> 

:EXITED
0
commented

Maybe it's the reason that version of python or multiple versions exists caused these errors.

commented

giving the pathname of execute Python program also can't work.

CL-USER> (setf py4cl:*python-command* "C:/Program Files/Python36/python.exe")
"C:/Program Files/Python36/python.exe"
CL-USER> (ql:quickload :py4cl/tests)
To load "py4cl/tests":
  Load 1 ASDF system:
    py4cl/tests
; Loading "py4cl/tests"

; file: C:/Users/chuangxiu.chen/quicklisp/dists/quicklisp/software/py4cl-20200925-git/tests/tests.lisp
; in: PY4CL:IMPORT-MODULE "math"
;     (PY4CL:IMPORT-MODULE "math" :RELOAD T)
; 
; caught ERROR:
;   (during macroexpansion of (PY4CL:IMPORT-MODULE "math" ...))
;   end of file on #<SB-SYS:FD-STREAM for "descriptor 972" {100A041423}>
[package py4cl/tests].....................

There definitely were a few errors on windows - particularly the case of '\r\n' vs '\n' (edit) and something to do with stream encodings. I had gotten py4cl2 version 2.4.1 to work on windows, not sure about the latest release.

commented

Thank you and I'll use the py4cl2 version 2.4.1 to deal with my project first

Could you also test the latest release?

Also, @bendudson, it might be possible to backport those fixes without breaking things, let me know (or feel free to cherry-pick) if I should create a PR (three are pending! one has prolly gotten a bit outdated), I could create one when I find some free time.

commented

OK,let me change a computer and have tries again.It doesn't work on this computer currently.And I will also read and learn your code to try understand the principle and do my best to make it works

commented

The latest release came with the same errors when change a computer

commented

Great! The latest release of py4cl2 works on windows system well,except that you must running Emacs or SBCL from the command line so your PATH environment variable will be set.According to the suggestions of dear Mark Watson's book at the chapter "Trouble Shooting Possible Problems - Skip if this Example Works on Your System".
In order to avoid errors,challenge you use the tool Anaconda to install Python and related packages.And ensure there only one version of python exists.
Thanks for the contributor's hardworking efforts.

commented

Dear Contributor,
would you mind to telling me which the differences of PY4CL and PY4CL2 that makes the PY4CL can works well on Windows system,on the contrary,PY4CL can't.
What is the theory of this?