Open daviddhtn opened 4 years ago
The problem is the kpsewhich function in webquiz_util.py does not work in windows 10 Error in Line 40: subprocess.check_output('kpsewhich ' + search, shell=True).decode('ascii').strip() It should be modified like this subprocess.check_output(['kpsewhich','-var-value', search]).decode('ascii').strip() but some search term in webquiz.py must be edited
No, this is not the problem. The shell=True changes the syntax of the subprocess.check.output command. To confirm this I just checked this "by hand" on a windows 10 machine and it works fine:
subprocess.check_output('kpsewhich -var-value TEXMFMAIN', shell=True) kpsewhich: warning: running with administrator privileges b'C:/Program Files/MiKTeX 2.9\r\n'
According to your original error message the problem that you are actually having is with the command:
kpsewhich -var-value TEXMFMAIN
What happens when you run this in a terminal window? The expected output is something like the following:
kpsewhich -var-value TEXMFMAIN C:/Program Files/MiKTeX 2.9
On Tue, 7 Apr 2020 at 21:07, daviddhtn notifications@github.com wrote:
The problem is the kpsewhich function in webquiz_util.py does not work in wwindows 10 Error in Line 40: subprocess.check_output('kpsewhich ' + search, shell=True).decode('ascii').strip() It should be modified like this subprocess.check_output(['kpsewhich','-var-value', search]).decode('ascii').strip() but some search term in webquiz.py must be edited
— You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub https://github.com/AndrewAtLarge/WebQuiz/issues/7#issuecomment-610323817, or unsubscribe https://github.com/notifications/unsubscribe-auth/AGLA5N23NH5AM4MNDWY2F2TRLMCN3ANCNFSM4MCY52ZQ .
Hi AndrewAtLarge In terminal window, it works well. C:\WINDOWS\system32>kpsewhich -var-value TEXMFMAIN kpsewhich: security risk: running with elevated privileges C:/Program Files/MiKTeX 2.9
No, this is not the problem. The shell=True changes the syntax of the subprocess.check.output command. To confirm this I just checked this "by hand" on a windows 10 machine and it works fine:
subprocess.check_output('kpsewhich -var-value TEXMFMAIN', shell=True) kpsewhich: warning: running with administrator privileges b'C:/Program Files/MiKTeX 2.9\r\n' According to your original error message the problem that you are actually having is with the command: kpsewhich -var-value TEXMFMAIN What happens when you run this in a terminal window? The expected output is something like the following: kpsewhich -var-value TEXMFMAIN C:/Program Files/MiKTeX 2.9 … On Tue, 7 Apr 2020 at 21:07, daviddhtn @.***> wrote: The problem is the kpsewhich function in webquiz_util.py does not work in wwindows 10 Error in Line 40: subprocess.check_output('kpsewhich ' + search, shell=True).decode('ascii').strip() It should be modified like this subprocess.check_output(['kpsewhich','-var-value', search]).decode('ascii').strip() but some search term in webquiz.py must be edited — You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub <#7 (comment)>, or unsubscribe https://github.com/notifications/unsubscribe-auth/AGLA5N23NH5AM4MNDWY2F2TRLMCN3ANCNFSM4MCY52ZQ .
Can you try installing with:
webquiz --debugging -i
and post the output around any error messages that you get.
WebQuiz error: unknown problem.
If you think this is a bug please report it by creating an issue at github.com/AndrewAtLarge/WebQuiz/issues
File: C:\Users...\AppData\Local\Programs\Python\Python37\lib\subprocess.py, line number: 487
Error Command 'kpsewhich -var-value TEXMFLOCAL' returned non-zero exit status 1. in run: output=stdout, stderr=stderr)
Traceback (most recent call last):
File "webquiz.py", line 1124, in
C:\Users...\Desktop\webquiz\scripts>
webquiz --debugging -i
Actually, I just test the simple code [code] import os import subprocess import webquiz_util TEXMFLOCAL='' try: TEXMFLOCAL = webquiz_util.kpsewhich('-var-value TEXMFMAIN') except subprocess.CalledProcessError: pass
if TEXMFLOCAL == '':
TEXMFLOCAL = webquiz_util.kpsewhich('-var-value TEXMFLOCAL')
print(TEXMFLOCAL)
[/code]
but it does not work,
The error here
[code]
C:\Users...\Desktop\webquiz\scripts>python test.py
The system cannot find the path specified.
kpsewhich: security risk: running with elevated privileges
The system cannot find the path specified.
kpsewhich: security risk: running with elevated privileges
Traceback (most recent call last):
File "test.py", line 11, in
Since you are happy running python let's cut down to the actual problem. What does the following do:
import subprocess
subprocess.check_output('kpsewhich -var-value TEXMFMAIN', shell=True)
subprocess.check_output('kpsewhich -var-value TEXMFMAIN', shell=True).decode('ascii')
subprocess.check_output('kpsewhich -var-value TEXMFMAIN', shell=True).decode('ascii').strip()
Btw, I notice that in the errors above sometimes you have a problem with TEXMFLOCAL and other times with TEXMFMAIN, which is a little strange.
Hi AndrewAtLarge, That simple code does not work, C:\Users\NGOCTU\Desktop\webquiz\scripts>python test1.py The system cannot find the path specified. kpsewhich: security risk: running with elevated privileges Traceback (most recent call last): File "test1.py", line 2, in subprocess.check_output('kpsewhich -var-value TEXMFMAIN', shell=True) File "C:\Users\NGOCTU\AppData\Local\Programs\Python\Python37\lib\subprocess.py", line 395, in check_output **kwargs).stdout File "C:\Users\NGOCTU\AppData\Local\Programs\Python\Python37\lib\subprocess.py", line 487, in run output=stdout, stderr=stderr) subprocess.CalledProcessError: Command 'kpsewhich -var-value TEXMFMAIN' returned non-zero exit status 1.
C:\Users\NGOCTU\Desktop\webquiz\scripts>python --version Python 3.7.2 "
Since you are happy running python let's cut down to the actual problem. What does the following do:
import subprocess subprocess.check_output('kpsewhich -var-value TEXMFMAIN', shell=True) subprocess.check_output('kpsewhich -var-value TEXMFMAIN', shell=True).decode('ascii') subprocess.check_output('kpsewhich -var-value TEXMFMAIN', shell=True).decode('ascii').strip()
I try to change the order of the search terms in webquiz.py so may be you can see the out put error at TEXMFMAIN or TEXMFLOCAL " TEXMFLOCAL='' try: TEXMFLOCAL = webquiz_util.kpsewhich('-var-value TEXMFMAIN') except subprocess.CalledProcessError: pass if TEXMFLOCAL == '': TEXMFLOCAL = webquiz_util.kpsewhich('-var-value TEXMFLOCAL') self.system_rcfile = os.path.join(TEXMFLOCAL, 'tex', 'latex', 'webquiz', 'webquizrc') self.read_webquizrc(self.system_rcfile) "
Btw, I notice that in the errors above sometimes you have a problem with TEXMFLOCAL and other times with TEXMFMAIN, which is a little strange.
The problem is not with webquiz
because the python code that I asked you to run simply executes:
kpsewhich -var-value TEXMFMAIN
from inside the python shell.
So I think that something must be wrong with your MikTeX configuration. What I do not understand, however, is why the kpsewhich
command works for you when you run it from a terminal. As far as I can tell, python is finding the kpsewhich
command BUT kpsewhich
is not finding the TEXMFMAIN
and TEXMFLOCAL
environment variables.
I don't know too, I think the problem may from the python version 3.7.2 64 bits. The Miktex run well. C:\WINDOWS\system32>latex --version latex: security risk: running with elevated privileges MiKTeX-pdfTeX 2.9.7338 (1.40.21) (MiKTeX 2.9.7380 64-bit) Copyright (C) 1982 D. E. Knuth, (C) 1996-2020 Han The Thanh TeX is a trademark of the American Mathematical Society. using bzip2 version 1.0.6, 6-Sept-2010 compiled with curl version 7.61.1; using libcurl/7.61.1 WinSSL compiled with expat version 2.2.6; using expat_2.2.6 compiled with jpeg version 9.3 compiled with liblzma version 50020042; using 50020042 compiled with libpng version 1.6.37; using 1.6.37 compiled with libressl version LibreSSL 2.8.2; using LibreSSL 2.8.2 compiled with MiKTeX Application Framework version 4.7348; using 4.7348 compiled with MiKTeX Core version 16.7375; using 16.7375 compiled with MiKTeX Archive Extractor version 1.6882; using 1.6882 compiled with MiKTeX Package Manager version 9.7364; using 9.7364 compiled with poppler version 0.60.1 compiled with uriparser version 0.9.2 compiled with zlib version 1.2.11; using 1.2.11
C:\WINDOWS\system32>kpsewhich -var-value TEXMFMAIN kpsewhich: security risk: running with elevated privileges C:/Program Files/MiKTeX 2.9
The problem is not with
webquiz
because the python code that I asked you to run simply executes:kpsewhich -var-value TEXMFMAIN
from inside the python shell.
So I think that something must be wrong with your MikTeX configuration. What I do not understand, however, is why the
kpsewhich
command works for you when you run it from a terminal. As far as I can tell, python is finding thekpsewhich
command BUTkpsewhich
is not finding theTEXMFMAIN
andTEXMFLOCAL
environment variables.
I edit the code like below and It works well
import subprocess
import os
print(subprocess.check_output(['kpsewhich','-var-value','TEXMFMAIN']))
print(subprocess.check_output(['kpsewhich','-var-value','TEXMFMAIN']).decode('ascii'))
print(subprocess.check_output(['kpsewhich','-var-value','TEXMFMAIN']).decode('ascii').strip())
Test
C:\Users...\Desktop\webquiz\scripts>python test1.py
kpsewhich: security risk: running with elevated privileges
b'C:/Program Files/MiKTeX 2.9\r\n'
kpsewhich: security risk: running with elevated privileges
C:/Program Files/MiKTeX 2.9
kpsewhich: security risk: running with elevated privileges
C:/Program Files/MiKTeX 2.9
The problem is not with
webquiz
because the python code that I asked you to run simply executes:kpsewhich -var-value TEXMFMAIN
from inside the python shell.
So I think that something must be wrong with your MikTeX configuration. What I do not understand, however, is why the
kpsewhich
command works for you when you run it from a terminal. As far as I can tell, python is finding thekpsewhich
command BUTkpsewhich
is not finding theTEXMFMAIN
andTEXMFLOCAL
environment variables.
Strange. I don't understand this as both syntaxes for subprocess.check_output
should work. Still, thanks for your detective work.
I can't attach a python file to this message. Can you try editting webquiz_util.py
and replacing the kpsewhich
function (line 34) with the following:
def kpsewhich(search):
r'''
Short-cut to access kpsewhich output.
usage: kpsewhich('-var-value=TEXMFLOCAL')
'''
try:
return subprocess.check_output(['kpsewhich']+search.split()).decode('ascii').strip()
except subprocess.CalledProcessError as err:
webquiz_error(True, f'Error with "kpsewhich {search}"', err=err)
I wonder, does the following python code return b'C:/Program Files/MiKTeX 2.9\r\n'
?
import subprocess
subprocess.check_output('kpsewhich -var-value=TEXMFMAIN', shell=True)
It does not work, dear AndrewAtLarge
I wonder, does the following python code return
b'C:/Program Files/MiKTeX 2.9\r\n'
?import subprocess subprocess.check_output('kpsewhich -var-value=TEXMFMAIN', shell=True)
What you ran is slightly different to what I posted above: note the equals sign =
between the -var-value
and the TEXMFMAIN
. I suspect that it won't work either, but I am curious.
Have you tried the changes above that I posted for the kpsewhich
command in webquiz_util.py
?
It also does not work
What you ran is slightly different to what I posted above: note the equals sign
=
between the-var-value
and theTEXMFMAIN
. I suspect that it won't work either, but I am curious.Have you tried the changes above that I posted fr the
kpsewhich
command inwebquiz_util.py
?
As suggested above, can you please try editing webquiz_util.py
and replacing the kpsewhich
function (line 34) with the following code:
def kpsewhich(search):
r'''
Short-cut to access kpsewhich output.
usage: kpsewhich('-var-value=TEXMFLOCAL')
'''
try:
return subprocess.check_output(['kpsewhich']+search.split()).decode('ascii').strip()
except subprocess.CalledProcessError as err:
webquiz_error(True, f'Error with "kpsewhich {search}"', err=err)
and letting me know if this fixes the problem. Given this issue, I should change the other subprocessor calls that use shell-True
as well.
It is late for me, so I will check tomorrow morning. It is funny that it works for me but I am grateful that you identified the problem. Thanks.
Good morning AndrewAtLarge,
I am sorry for replying late,
I try to edit webquiz_util.py, install and then edit the line 41 in webquiz.py
ini_file = os.path.join(webquiz_util.webquiz_file(''), '..', 'latex', 'webquiz.ini')
to
ini_file = os.path.join(webquiz_util.webquiz_file(''), '', 'latex', 'webquiz.ini')
After finishing initialise, I test for a simple text file but receive this error. I am trying upgrade all packages of the Miktex and hope it works.
Thanh you very much
As suggested above, can you please try editing
webquiz_util.py
and replacing thekpsewhich
function (line 34) with the following code:def kpsewhich(search): r''' Short-cut to access kpsewhich output. usage: kpsewhich('-var-value=TEXMFLOCAL') ''' try: return subprocess.check_output(['kpsewhich']+search.split()).decode('ascii').strip() except subprocess.CalledProcessError as err: webquiz_error(True, f'Error with "kpsewhich {search}"', err=err)
and letting me know if this fixes the problem. Given this issue, I should change the other subprocessor calls that use
shell-True
as well.It is late for me, so I will check tomorrow morning. It is funny that it works for me but I am grateful that you identified the problem. Thanks.
I am very sorry for disturbing you again, I have installed on three computers (two with Texlive 2019 and another with MiKTeX 2.9.7380 64-bit, all are complete packages ) but can not compile a simple example
\documentclass{webquiz}
\title{An easy example}
\begin{document}
\begin{question} % a quiz question
Alice is twice as old as Betty.
Betty is one year older than Claire.
If Alice is $4$ how old is Claire?
\begin{choice}[columns=2] % multiple choice question
\correct $1$ % first choice - correct answer
\feedback If Claire is $1$ then Betty is $2$ and Alice is~$4$!
\incorrect $2$ % second choice - incorrect
\feedback If Claire is $2$ then Betty is $3$ and Alice is~$6$.
\incorrect $3$ % third choice - incorrect
\feedback If Claire is $3$ then Betty is $4$ and Alice is~$8$.
\incorrect $4$ % fourth choice - incorrect
\feedback If Claire is $4$ then Betty is $5$ and Alice is~$10$.
\end{choice}
\end{question}
\end{document}
Here are error in compile and display web
You are getting the same error as before. This is what the The system cannot find the path specified.
messages mean. I think that you cannot have replaced the definition of the kpsewhich
function with the code that I posted above because if you had then the program would exit with an error rather than continuing. Please tell me what changes you made to my code as I honestly can't help if I don't know what you have done.
I am also confused as to why you said you changed the line
ini_file = os.path.join(webquiz_util.webquiz_file(''), '..', 'latex', 'webquiz.ini')
If webquiz is properly installed then this line of code never gets called. YOu only saw it because the kpsewhich
command is still failing.
Dear AndrewAtLarge Here is my experience, 1- For Windows 10 v.1903 (64bits) + and MiKTeX 2.9.7380 (64bits) + Python 3.7.2 (64bits) a- It does not work if webquiz is installed directly via miktex package manager
try:
return subprocess.check_output(['kpsewhich']+search.split()).decode('ascii').strip()
except subprocess.CalledProcessError as err:
webquiz_error(True, f'Error with "kpsewhich {search}"', err=err)
b1-Delete every folder related to webquiz, unzip the original webquiz.zip then copy to C:\Program Files\MiKTeX 2.9\scripts. It still cannot install (error as in case 2a)
b2- Edit the webquiz_util.py as your suggestion, still error in
c- I try to edit some codes at %AppData%\Roaming\MiKTeX\2.9\scripts\webquiz
Line 41 in webquiz.py in %AppData%\Roaming\MiKTeX\2.9\scripts\webquiz to
ini_file = os.path.join(webquiz_util.webquiz_file(''), '', 'latex', 'webquiz.ini')
Line 34 in webquiz_util.py as your suggestion
Now, it got some error (may be not from your code but make4ht)
3- Test the output file
I run local web server using XAMPP with PHP 7.4.4
It works well now,
I'll post my experience in Texlive 2019 later,
Thank you very much for your help,
David, in all of your output above you see many times
The system cannot find the path specified
These messages seem to be an error generated by the windows OS because it cannot find something in your system path. See for example https://superuser.com/questions/727316/error-in-command-line-the-system-cannot-find-the-path-specified. I wonder what command is missing from your path and what effect this is having.
I am unable to reproduce your errors and the syntax change for using subprocess.check_output
does not make sense to me because all of the classes in the standard python libraries should work in the same way on all systems - and this code works for me on a windows machine.
This said, I don't use windows so the program is certainly not as well tested on this OS.
Please help, I cannot install webquiz on Miktex 2.9.7364, here are errors File: C:\Users...\AppData\Local\Programs\Python\Python37\lib\subprocess.py, line number: 487 Error Command 'kpsewhich -var-value TEXMFMAIN' returned non-zero exit status 1. in run: output=stdout, stderr=stderr) Traceback (most recent call last): File "webquiz.py", line 1124, in
.format(metadata.repository), err)
File "webquiz.py", line 808, in
settings = WebQuizSettings()
File "webquiz.py", line 237, in init
TEXMFLOCAL = webquiz_util.kpsewhich('-var-value TEXMFMAIN')
File "C:\Program Files\MiKTeX 2.9\scripts\webquiz\scripts\webquiz_util.py", line 40, in kpsewhich
return subprocess.check_output('kpsewhich ' + search, shell=True).decode('ascii').strip()
File "C:\Users...\AppData\Local\Programs\Python\Python37\lib\subprocess.py", line 395, in check_output
**kwargs).stdout
File "C:\Users....\AppData\Local\Programs\Python\Python37\lib\subprocess.py", line 487, in run
output=stdout, stderr=stderr)
subprocess.CalledProcessError: Command 'kpsewhich -var-value TEXMFMAIN' returned non-zero exit status 1.