nikademus79 / psutil

Automatically exported from code.google.com/p/psutil
Other
0 stars 0 forks source link

python3 issues, psutil/__init__.py:427 #199

Closed GoogleCodeExporter closed 8 years ago

GoogleCodeExporter commented 8 years ago
What steps will reproduce the problem?
1.import psutil
2.
3.

What is the expected output? What do you see instead?
>>> import psutil
>>>
...
>>> import psutil
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "psutil/__init__.py", line 427
    except OSError, err:
                  ^
SyntaxError: invalid syntax

What version of psutil are you using? What Python version?
0.3.0, python 3.2

On what operating system? Is it 32bit or 64bit version?
linux and freebsd, both

Please provide any additional information below.
py3 uses: except Exception as xyz: form, not Exception, xyz

Original issue reported on code.google.com by firefigh...@gmail.com on 25 Aug 2011 at 1:38

GoogleCodeExporter commented 8 years ago
actually, there's a whole bunch of py2 only syntax.  looking at setup.py, it 
looks like the 2to3 hack isn't working as desired

Original comment by firefigh...@gmail.com on 25 Aug 2011 at 1:46

GoogleCodeExporter commented 8 years ago
perhaps this small addition, that fixes everything for me

setup(...
  use_2to3=True
)

Original comment by firefigh...@gmail.com on 25 Aug 2011 at 1:58

GoogleCodeExporter commented 8 years ago
It's likely you first installed psutil for python 2.x. Am I right?
In this case you have to remove build directory before installing psutil.
In summary:

$ python2.7 setup.py install
$ rm -rf build
$ python3.2 setup.py install

Please let me know if this fixes the problem.

Original comment by g.rodola on 25 Aug 2011 at 4:29

GoogleCodeExporter commented 8 years ago
nope, no 2.7, just 3.2.  tar xf, cd psutil.., python setup.py install, cd /,
python -c 'import psutil'

my suggested fix comes straight from the python wiki for porting 2 to 3

-david

Original comment by firefigh...@gmail.com on 28 Aug 2011 at 1:07

GoogleCodeExporter commented 8 years ago
AFAIK use_2to3 option is for distribute only:
http://docs.python.org/dev/howto/pyporting.html#during-installation
I can add it but it shouldn't make any difference.

Have you tried to download psutil tarball again and unpack it in a brand new 
directory and then install it with "python3.2 setup.py install"?
In psutil's setup.py file we've been using the trick mentioned in the link 
above:

try:
    from distutils.command.build_py import build_py_2to3 as build_py
except ImportError:
    from distutils.command.build_py import build_py

...and that worked fine so far.

Original comment by g.rodola on 2 Sep 2011 at 11:43

GoogleCodeExporter commented 8 years ago
hmm, going back and restarting everything, you're right.  i can't reproduce
things as i saw them

Original comment by firefigh...@gmail.com on 7 Sep 2011 at 7:13

GoogleCodeExporter commented 8 years ago

Original comment by g.rodola on 8 Sep 2011 at 8:29