[Tutor] localhosting
Roger Lea Scherer
rls4jc at gmail.com
Thu Sep 6 15:09:12 EDT 2018
Thank you all for your help. I am still chugging away at this problem. I've
switched to Windows PowerShell Version 5.1 since I can select, copy, and
paste more easily in PowerShell. (I can't figure out how to do that in
Anaconda and I get the same errors in PowerShell.)
I removed the "3" in "python3" and it works; along with moving the "www"
folder to where python resides. Thanks for the help.
So it appears the local host is running correctly, but when I run this code:
print("Hello World")
Chrome does not render and I get an error message in PowerShell:
127.0.0.1 - - [06/Sep/2018 11:22:46] "GET /cgi-bin/hello.py HTTP/1.1" 200 -
127.0.0.1 - - [06/Sep/2018 11:22:46] command:
C:\Users\Roger\AppData\Local\Programs\Python\Python37-32\python.exe -u
C:\Users\Roger\documents\roger\python\www\cgi-bin\hello.py ""
127.0.0.1 - - [06/Sep/2018 11:22:46] b' File
"C:\\Users\\Roger\\documents\\roger\\python\\www\\cgi-bin\\hello.py", line
1\r\n print "<html>"\r\n ^\r\nSyntaxError: Missing
parentheses in call to \'print\'. Did you mean print("<html>")?\r\n'
127.0.0.1 - - [06/Sep/2018 11:22:46] CGI script exit status 0x1
BUT when I run this code:
def fib(n):
if n < 2:
return n
return fib(n-1) + fib(n-2)
print(fib(15))
Chrome does not render but I DON'T get an error message, I get this:
127.0.0.1 - - [06/Sep/2018 11:33:30] "GET /cgi-bin/recursive%20fibonacci.py
HTTP/1.1" 200 -
127.0.0.1 - - [06/Sep/2018 11:33:30] command:
C:\Users\Roger\AppData\Local\Programs\Python\Python37-32\python.exe -u
"C:\Users\Roger\documents\roger\python\www\cgi-bin\recursive fibonacci.py"
""
127.0.0.1 - - [06/Sep/2018 11:33:30] CGI script exited OK
So I'm confused about 2 things:
1. Why does the one file cause an error in PowerShell (and Anaconda
actually) when it seems to be the same as the other file which appears to
run with no error, but just not render? and,
2. What am I missing: why won't it render since the instructions I have at
the very beginning of this email say, basically, this is all I have to do
to get it to render?
I know this second question is maybe a little bit outside this forum, but I
am struggling to make sense out of what little I know and, truly, this
forum seems the nicest and most helpful I've encountered.
Thank you as always.
On Thu, Aug 30, 2018 at 6:01 AM Mats Wichmann <mats at wichmann.us> wrote:
> On 08/30/2018 02:54 AM, Alan Gauld via Tutor wrote:
> > On 30/08/18 00:09, Roger Lea Scherer wrote:
> >> I'm trying to implement a local host. My instructions tell me to type
> the
> >> following command in the command line, make sure I'm in the "www" folder
> >
> > So this is not the folder where python3 is installed. (See below)
> >
> >> python3 -m http.server --cgi 8000
> >
> >> I'm running Anaconda in Windows 10. I get an error: 'python3' is not
> >> recognized as an internal or external command, operable program or batch
> >> file.
> >> But this is the folder that I thought Python 3.6 was in.
> >
> > you said you were in www which is not where Python should
> > be installed.
> >
> > It is likely that Python is not in your system PATH.
> > You need to find out where it is installed and add it.
> > In a standard Python install it would either be in
> > C:\PROGRAM FILES\PYTHON or
> > C:\PYTHON
> >
> > But Anaconda (version please?) could use its own path
> > such as
> >
> > C:\ANACONDA\PYTHON
> >
> >> So how do I correct this? I suspect python3 isn't in this folder. I
> know I
> >> have python3 because I run python3.6 shell practically every day.
> >
> > How do you run it?
> >>From a command line or via a menu/shortcut?
> >
> >> looked in the Program Files folder, came up empty as far as python is
> >> concerned, but I don't know where else to look?
>
> Several things that could help:
>
> you can ask python itself to tell you where it is, since you say python
> works for you.
>
> >>> import sys
> >>> print(sys.executable)
>
> the standard Windows python defaults to a "user install", so it could be
> in a place like
>
> {yourhomdirectory}/AppData/Local/Programs/Python
>
> Anaconda, as Alan says, likely puts it somewhere different.
>
> Python 3 isn't named python3 on Windows unless you take steps to make it
> so, it's just called python. So modify your instructions accordingly.
>
> Also on Windows, if it was installed, there is a separate thing called
> the Python Launcher, which lets you run the command "py" which typically
> gets put in a place that is always found, and avoids the fiddling with
> getting Python itself into your PATH. But I'm unsure whether the
> Anaconda install actually installs that. You could try... just type: py
>
>
> _______________________________________________
> Tutor maillist - Tutor at python.org
> To unsubscribe or change subscription options:
> https://mail.python.org/mailman/listinfo/tutor
>
--
Roger Lea Scherer
623.255.7719
*Strengths:*
Input, Strategic,
Responsibility,
Learner, Ideation
More information about the Tutor
mailing list