[python-win32] Interactive Code to Script File

Vernon D. Cole vernondcole at gmail.com
Wed Sep 17 02:13:52 CEST 2014


Dear D.J.:
   First, let me mention that you violated several of the unwritten rules
of asking for help.
For example, the code you typed into for email is not the same as the code
in the picture
you sent as an attachment (using a proprietary format).
Code samples should be cut-and-paste, not retyped.
The unwritten rules have been summarized at
http://www.catb.org/~esr/faqs/smart-questions.html
<https://www.linkedin.com/redirect?url=http%3A%2F%2Fwww%2Ecatb%2Eorg%2F%7Eesr%2Ffaqs%2Fsmart-questions%2Ehtml&urlhash=VCfv&_t=tracking_disc>
This helps us help you.

Now to answer your question:

The code you typed in has an incorrect URL, but it reliably opens a browser
which informs me of that
fact when run as a script from the command line using Python versions from
2.3 to 3.4.

The only error in the code pictured in your attachment is the
over-specification of the Python version
in your #! line.  It is correct to specify the version to the second level,
like

> #!python2.7
>
 but specifying the third level is an error in the Python Launcher for
Windows (which you were not using.)
As a practical matter, your code is not at all version sensitive, so you
should simply use:

> #!/usr/bin/python
>

After I removed the offending ".8" that version of the program also
operated as expected in all versions tested.
I tried running it from the pythonwin IDE (as you were doing in the screen
capture) and it worked correctly
in Python 2.7 and 3.4.

This leads me to believe that the problem lies in your specific
installation of Python. In what way might your installation be unusual?
Might it, perhaps, have been installed without administrative privileges,
or  for only your user (not all users)?


On Tue, Sep 16, 2014 at 7:13 PM, DJ Webre <d_webre at yahoo.com.dmarc.invalid>
wrote:

> I am trying to convert a program from interactive to script file.
>
> The program consists of the following 2 lines:
>
> import webbrowser
> webbrowser.open_new('http://www.google')
>
> When I run it interactively, it works but if I run it as a scrip file, it
> produces an error unless I import webbrowser interactively.
>
> What am I doing wrong?
>
> Thanks in advance for any assistance.
>
> D. J.
>
> _______________________________________________
> python-win32 mailing list
> python-win32 at python.org
> https://mail.python.org/mailman/listinfo/python-win32
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/python-win32/attachments/20140917/e5330486/attachment.html>


More information about the python-win32 mailing list