Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.python > #94919 > unrolled thread
| Started by | Dwight GoldWinde <Dwight@GoldWinde.com> |
|---|---|
| First post | 2015-08-03 14:57 +0800 |
| Last post | 2015-08-03 12:49 +0300 |
| Articles | 6 — 5 participants |
Back to article view | Back to comp.lang.python
This discussion starts older than the indexed window; earlier articles aren't shown. The article labeled Started by
below is the oldest one visible, not the original post.
Re: I'm a newbie and I'm still stumped... Dwight GoldWinde <Dwight@GoldWinde.com> - 2015-08-03 14:57 +0800
Re: I'm a newbie and I'm still stumped... Paul Rubin <no.email@nospam.invalid> - 2015-08-03 00:14 -0700
FW: I'm a newbie and I'm still stumped... Dwight Hotmail <GoldWinde@hotmail.com> - 2015-08-03 16:19 +0800
Re: I'm a newbie and I'm still stumped... Dave Farrance <df@see.replyto.invalid> - 2015-08-03 09:27 +0100
Re: I'm a newbie and I'm still stumped... Dwight GoldWinde <Dwight@GoldWinde.com> - 2015-08-03 16:56 +0800
Re: I'm a newbie and I'm still stumped... Jussi Piitulainen <jpiitula@ling.helsinki.fi> - 2015-08-03 12:49 +0300
| From | Dwight GoldWinde <Dwight@GoldWinde.com> |
|---|---|
| Date | 2015-08-03 14:57 +0800 |
| Subject | Re: I'm a newbie and I'm still stumped... |
| Message-ID | <mailman.1171.1438585158.3674.python-list@python.org> |
Thank you, Emile, Paul, Terry, and Joel for your suggestions! And the
error persists.
Maybe my error is coming from running the old version (2.7.6) of Python,
but I can’t figure out why that would be happening???
I downloaded 3.4.3 again from the Python.org website for my Mac.
I inserted the "import sys" and did “print (sys.version)” into the code.
So here what the code is:
#!/usr/bin/env python3
import sys
print (sys.version)
word = input('Enter a word ')
Here are the results I got below, showing the same error. The first line
says,
"2.7.6 (default, Sep 9 2014, 15:04:36)”. Does that mean I am running the
old Python? How could that be since I am SURE I downloaded 3.4.3 (it even
gives the folder name as “Python 3.4” in the Applications folder on my Mac.
2.7.6 (default, Sep 9 2014, 15:04:36)
[GCC 4.2.1 Compatible Apple LLVM 6.0 (clang-600.0.39)]
Enter a word serendipity
Traceback (most recent call last):
File "test short.py", line 4, in <module>
word = input('Enter a word ')
File "<string>", line 1, in <module>
NameError: name 'serendipity' is not defined
Please help…
BIG SMILE...
Always, Dwight
www.3forliving.key.to (video playlist on YouTube)
www.couragebooks.key.to (all my books on Amazon)
#!/usr/bin/env python3
import sys
print (sys.version)
word = input('Enter a word ')
2.7.6 (default, Sep 9 2014, 15:04:36)
[GCC 4.2.1 Compatible Apple LLVM 6.0 (clang-600.0.39)]
Enter a word serendipity
Traceback (most recent call last):
File "test short.py", line 3, in <module>
word = input('Enter a word ')
File "<string>", line 1, in <module>
NameError: name 'serendipity' is not defined
On 8/2/15, 12:30 AM, "Emile van Sebille" <emile@fenx.com> wrote:
>On 7/30/2015 6:22 PM, Dwight GoldWinde wrote:
>> I am running Python 3.4 on my Mac mini, OS X 10.10.2, using Coderunner
>>2 as
>> my editor.
>>
>> Here¹s the code:
>> #!/usr/bin/env python3
>> word = (input('Enter a word Œ))
>>
>> When running this inside of Coderunner, I get the follow error, after
>> entering the word Œserendipity¹:
>>
>> Enter a word serendipity
>> Traceback (most recent call last):
>> File "test short.py", line 2, in <module>
>> word = (input('Enter a word '))
>> File "<string>", line 1, in <module>
>> NameError: name 'serendipity' is not defined
>
>I'd look at which python is actually running (sys.version):
>
>Python 3.4.0 (default, Apr 11 2014, 13:05:11)
>[GCC 4.8.2] on linux
>Type "help", "copyright", "credits" or "license" for more information.
> >>> word = (input('enter a word '))
>enter a word test
> >>>
>emile@emile-OptiPlex-9010:~$ python
>Python 2.7.6 (default, Mar 22 2014, 22:59:56)
>[GCC 4.8.2] on linux2
>Type "help", "copyright", "credits" or "license" for more information.
> >>> word = (input('enter a word '))
>enter a word test
>Traceback (most recent call last):
>
>
>Emile
> File "<stdin>", line 1, in <module>
> File "<string>", line 1, in <module>
>NameError: name 'test' is not defined
> >>>
>
>
>
>--
>https://mail.python.org/mailman/listinfo/python-list
[toc] | [next] | [standalone]
| From | Paul Rubin <no.email@nospam.invalid> |
|---|---|
| Date | 2015-08-03 00:14 -0700 |
| Message-ID | <87io8wkfn9.fsf@jester.gateway.sonic.net> |
| In reply to | #94919 |
Dwight GoldWinde <Dwight@GoldWinde.com> writes:
> word = input('Enter a word ')
Use raw_input instead of input. In python 2.x, input treats the stuff
you enter as a Python expression instead of a string.
[toc] | [prev] | [next] | [standalone]
| From | Dwight Hotmail <GoldWinde@hotmail.com> |
|---|---|
| Date | 2015-08-03 16:19 +0800 |
| Message-ID | <mailman.1177.1438598158.3674.python-list@python.org> |
| In reply to | #94920 |
On 8/3/15, 4:07 PM, "Dwight GoldWinde" <Dwight@GoldWinde.com> wrote:
>Thank you, Paul.
>
>But does this mean I am not using Python 3.4?
>
>BIG SMILE...
>
>Always, Dwight
>
>
>www.3forliving.key.to (video playlist on YouTube)
>www.couragebooks.key.to (all my books on Amazon)
>
>
>
>
>
>
>On 8/3/15, 3:14 PM, "Paul Rubin" <no.email@nospam.invalid> wrote:
>
>>Dwight GoldWinde <Dwight@GoldWinde.com> writes:
>>> word = input('Enter a word ')
>>
>>Use raw_input instead of input. In python 2.x, input treats the stuff
>>you enter as a Python expression instead of a string.
>>--
>>https://mail.python.org/mailman/listinfo/python-list
[toc] | [prev] | [next] | [standalone]
| From | Dave Farrance <df@see.replyto.invalid> |
|---|---|
| Date | 2015-08-03 09:27 +0100 |
| Message-ID | <ts8uradnhvig3rt9f3h3rs4prppqhflvo4@4ax.com> |
| In reply to | #94919 |
Dwight GoldWinde <Dwight@GoldWinde.com> wrote: >Here are the results I got below, showing the same error. The first line >says, >"2.7.6 (default, Sep 9 2014, 15:04:36)”. Does that mean I am running the >old Python? How could that be since I am SURE I downloaded 3.4.3 (it even >gives the folder name as “Python 3.4” in the Applications folder on my Mac. Yes, that's Python2. I've never used MAC OS, but I understand that it has the BASH shell, so you can use "which" try to figure out where python is being found on the path: $ echo $PATH $ which python Use the above to also check for the position of python2 and python3. You can check for aliases and links with the "type" and "file" commands. Do this for python, python2 and python3: $ type $(which python) $ file $(which python)
[toc] | [prev] | [next] | [standalone]
| From | Dwight GoldWinde <Dwight@GoldWinde.com> |
|---|---|
| Date | 2015-08-03 16:56 +0800 |
| Message-ID | <mailman.1172.1438594259.3674.python-list@python.org> |
| In reply to | #94921 |
On 8/3/15, 4:55 PM, "Dwight GoldWinde" <Dwight@GoldWinde.com> wrote: >Okay, thank you, Dave, so I got the following info: >type $(which python3) >/Library/Frameworks/Python.framework/Versions/3.4/bin/python3 is >/Library/Frameworks/Python.framework/Versions/3.4/bin/python3 > > >But I can¹t figure out what short of ³usr² statement (e.g. #!/usr/bin/env >python3) I need to point it there. Whatever I tried, still gives me >version 2. > >??? > >Dwight > >On 8/3/15, 4:27 PM, "Dave Farrance" <df@see.replyto.invalid> wrote: > >>Dwight GoldWinde <Dwight@GoldWinde.com> wrote: >> >>>Here are the results I got below, showing the same error. The first line >>>says, >>>"2.7.6 (default, Sep 9 2014, 15:04:36)². Does that mean I am running the >>>old Python? How could that be since I am SURE I downloaded 3.4.3 (it >>>even >>>gives the folder name as ³Python 3.4² in the Applications folder on my >>>Mac. >> >>Yes, that's Python2. I've never used MAC OS, but I understand that it >>has the BASH shell, so you can use "which" try to figure out where >>python is being found on the path: >> >>$ echo $PATH >> >>$ which python >> >>Use the above to also check for the position of python2 and python3. >> >>You can check for aliases and links with the "type" and "file" commands. >>Do this for python, python2 and python3: >> >>$ type $(which python) >> >>$ file $(which python) >>-- >>https://mail.python.org/mailman/listinfo/python-list
[toc] | [prev] | [next] | [standalone]
| From | Jussi Piitulainen <jpiitula@ling.helsinki.fi> |
|---|---|
| Date | 2015-08-03 12:49 +0300 |
| Message-ID | <lf538008zxh.fsf@ling.helsinki.fi> |
| In reply to | #94922 |
Dwight GoldWinde quotes himself: > >> Okay, thank you, Dave, so I got the following info: type $(which >> python3) >> /Library/Frameworks/Python.framework/Versions/3.4/bin/python3 is >> /Library/Frameworks/Python.framework/Versions/3.4/bin/python3 >> >> But I can¹t figure out what short of ³usr² statement >> (e.g. #!/usr/bin/env python3) I need to point it there. Whatever I >> tried, still gives me version 2. How are you launching your script? If your method involves clicking some pretty picture or something similar, you may be bypassing /usr/bin/env altogether and relying on some association of file types in Mac OS. Then you need to investigate file properties in Finder, or something like that. It should be safe to change the association for that individual script but not necessarily for all files with the same extension. If your method is to type "python scriptname" at the shell prompt, you are definitely bypassing /usr/bin/env and specifying the default python as the one to use. Solution: type "python3 scriptname" instead. (A more advanced solution: make scriptname executable and type "./scriptname" instead. This one uses /usr/bin/env to find the interpreter.) (You could try "#!/usr/bin/env aintgotnosuch" as your script's hashbang line to see if it even matters what that line says. Check first that you don't happen to have a program named "aintgotnosuch" in your path.)
[toc] | [prev] | [standalone]
Back to top | Article view | comp.lang.python
csiph-web