NameError: name 'pyver' is not defined

  • Thread starter שולמית מירל
  • Start date
×

שולמית מירל

Hello,

We have python 2.6 & 3.2 installed on Sun solaris.
When running py utility, we get the below error:

"NameError: global name 'execfile' is not defined"

p4convert-cvs.py
EXCEPTION: [Errno 17] File exists: './LOGS'
Traceback (most recent call last):
File "p4convert-cvs.py", line 134, in <module>
cvstop4lib.readconfig(configfile=args.config)
File "/bzqchome/bzq/ccbzq/mb_ccbzq/Perforce/p4convert/cvstop4lib.py", line 61, in readconfig
execfile(configfile,globals()) # read in the config file - must be valid Python, evaluated in the context of this file
NameError: global name 'execfile' is not defined


How to solve this problem?

Thank you!
 
S

Steven D'Aprano

Hello,

We have python 2.6 & 3.2 installed on Sun solaris. When running py
utility, we get the below error:

"NameError: global name 'execfile' is not defined"

Sounds like you are accidentally running a script intended for Python2.6
under Python3.2 instead.

execfile is removed from 3.2, so you need to either edit the script to
update it for 3.2, or you need to make sure you are running it under 2.6.

Do you need help with that?
 
N

Ned Deily

We have python 2.6 & 3.2 installed on Sun solaris.
When running py utility, we get the below error:

"NameError: global name 'execfile' is not defined"

p4convert-cvs.py
EXCEPTION: [Errno 17] File exists: './LOGS'
Traceback (most recent call last):
File "p4convert-cvs.py", line 134, in <module>
cvstop4lib.readconfig(configfile=args.config)
File "/bzqchome/bzq/ccbzq/mb_ccbzq/Perforce/p4convert/cvstop4lib.py", line
61, in readconfig
execfile(configfile,globals()) # read in the config file - must be valid
Python, evaluated in the context of this file
NameError: global name 'execfile' is not defined

execfile() no long exists in Python 3 so chances are you are trying to
run a Python 3 program with Python 2. Try running the script explicitly
under Python 2:

python2.6 p4convert-cvs.py

You may have inadvertently done a "make install" with Python 3.2 that
has created a link from "python" to "python3.2". Later versions of
Python 3 are a little more careful about reserving "python" for Python 2
and "python3" for Python 3, although some distributions (notably Arch
Linux) do it differently.
 
N

Ned Deily

execfile() no long exists in Python 3 so chances are you are trying to
run a Python 3 program with Python 2. Try running the script explicitly
under Python 2:

Er, "trying to run a Python 2 program with Python 3", of course.
 
×

שולמית מירל

בת×ריך ×™×•× ×—×ž×™×©×™, 6 במרץ 2014 10:26:34 UTC+2, מ×ת Ned Deily: > In article <[email protected]>, ?AIOE??OE?I <[email protected]> wrote: > We have python 2.6 & 3.2 installed on Sun solaris. > When running py utility, we get the below error: > > "NameError: global name 'execfile' is not defined" > > > > p4convert-cvs.py > EXCEPTION: [Errno 17] File exists: './LOGS' > Traceback (most recent call last): > File "p4convert-cvs.py", line 134, in <module> > cvstop4lib.readconfig(configfile=args.config) > File "/bzqchome/bzq/ccbzq/mb_ccbzq/Perforce/p4convert/cvstop4lib.py", line > 61, in readconfig > execfile(configfile,globals()) # read in the config file - must be valid > Python, evaluated in the context of this file > NameError: global name 'execfile' is not defined execfile() no long exists in Python 3 so chances are you are trying to run a Python 3 program with Python 2. Try running the script explicitly under Python 2: python2.6 p4convert-cvs.py You may have inadvertently done a "make install" with Python 3.2 that has created a link from "python" to "python3.2". Later versions of Python 3 are a little more carefulabout reserving "python" for Python 2 and "python3" for Python 3, althoughsome distributions (notably Arch Linux) do it differently. -- Ned Deily, (e-mail address removed) thanks for your help! I tried first to run the script under 2.6 version, but than the "argparse" was missing. I couldn't find python 2.7 for unix download.
 
×

שולמית מירל

I tried first to run the script under 2.6 version, but than the "argparse" was missing. I couldn't find python 2.7 for unix download
 
P

Pavan Rikhi

execfile(configfile,globals())

You could replace the above line in cvstop4lib.py with the following:

exec(open(configfile).read(), globals())

-----BEGIN PGP SIGNATURE-----
Version: GnuPG v2.0.22 (GNU/Linux)

iQJ8BAEBCgBmBQJTGDeUXxSAAAAAAC4AKGlzc3Vlci1mcHJAbm90YXRpb25zLm9w
ZW5wZ3AuZmlmdGhob3JzZW1hbi5uZXQxQTAyMzVDOUEzRDU1NDBBOTAwQjQxRTNB
NzM2QTM0MjhENTA2M0JCAAoJEKc2o0KNUGO7Y74QAKKmX8xEvNHusxFgH1JnAxwc
wyE94hFvkaEXMwWGHQ8kDdSxWpuXOVPg/SKcx1mk19AX9Z7W/l0TjViVK9rndP3x
CCG26G9f/qLPYrB8cRK1CkXAW6NGumwuGsUpQS871ZJYC03KA+XmOyzq7P8WwiaR
r1+0xssXmF5GZDL1kVa7bGfu2eMTMT3L41GtyKQDKlFA5Y8N7fj93pHbxFghW1k7
vFKqUVvUiTqkHe3XQK6aujc/mr9vW4a3z4ZBNnEPcto4C8AZYIZWtcM055YoN4DE
mj7rzCNvnxe/SeCppR6PcIgl03lkkYvN9LT1J0xdEII6m9kRMz5zFKoP9ajZ7D87
JYXDEJ1gc7DvLW5BLLzh7/gXwtyqLrnuiWSve3tjCKEw9Rpnj4ZK82OG6waPXDiA
bHHan+xTnKTSuvlLbvR4s3i23KuJA6VAtBp39nTGfkf4sjt6OcBE7TFKjWDaXhwf
D07gI07rqs5ZDzVFeKdQ9EtaWzZmiODffWxXCaV9NpGGE++hayIxq9RSg4khOcNI
TvcJioU5hkZhYFvKQr7XN3PHk6HxHLSMJFSQt+6PpkegPYSACpRc0sgcgcFctxRB
dZiXdV5CVmeJ7aycc/XH5zyt10VzDNDThxpD1k9kXMCwXeHznFpSR+KMt4zSnw9R
azyZAhm1sVfJSXtrHqEK
=2PiH
-----END PGP SIGNATURE-----
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,770
Messages
2,569,583
Members
45,075
Latest member
MakersCBDBloodSupport

Latest Threads

Top