Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Cannot use pytorch interpreter help function due to error #10480

Closed
KennethAdamMiller opened this issue Aug 13, 2018 · 8 comments
Closed

Cannot use pytorch interpreter help function due to error #10480

KennethAdamMiller opened this issue Aug 13, 2018 · 8 comments

Comments

@KennethAdamMiller
Copy link

Issue description

I can't use the help due to an error, and I've reinstalled torch for both python 2 and 3 and with both anaconda and my host python.

Code example

import torch
help(torch)
Traceback (most recent call last):
File "", line 1, in
File "/usr/local/Cellar/python/3.7.0/Frameworks/Python.framework/Versions/3.7/lib/python3.7/_sitebuiltins.py", line 103, in call
return pydoc.help(*args, **kwds)
File "/usr/local/Cellar/python/3.7.0/Frameworks/Python.framework/Versions/3.7/lib/python3.7/pydoc.py", line 1895, in call
self.help(request)
File "/usr/local/Cellar/python/3.7.0/Frameworks/Python.framework/Versions/3.7/lib/python3.7/pydoc.py", line 1954, in help
else: doc(request, 'Help on %s:', output=self._output)
File "/usr/local/Cellar/python/3.7.0/Frameworks/Python.framework/Versions/3.7/lib/python3.7/pydoc.py", line 1674, in doc
pager(render_doc(thing, title, forceload))
File "/usr/local/Cellar/python/3.7.0/Frameworks/Python.framework/Versions/3.7/lib/python3.7/pydoc.py", line 1667, in render_doc
return title % desc + '\n\n' + renderer.document(object, name)
File "/usr/local/Cellar/python/3.7.0/Frameworks/Python.framework/Versions/3.7/lib/python3.7/pydoc.py", line 385, in document
if inspect.ismodule(object): return self.docmodule(*args)
File "/usr/local/Cellar/python/3.7.0/Frameworks/Python.framework/Versions/3.7/lib/python3.7/pydoc.py", line 1136, in docmodule
for key, value in inspect.getmembers(object, inspect.isclass):
File "/usr/local/Cellar/python/3.7.0/Frameworks/Python.framework/Versions/3.7/lib/python3.7/inspect.py", line 325, in getmembers
names = dir(object)
TypeError: descriptor 'dir' of 'object' object needs an argument

System Info

Please copy and paste the output from our
environment collection script

PyTorch version: 0.4.1
Is debug build: No
CUDA used to build PyTorch: None

OS: Mac OSX 10.13.6
GCC version: Could not collect
CMake version: version 3.11.4

Python version: 2.7
Is CUDA available: No
CUDA runtime version: No CUDA
GPU models and configuration: No CUDA
Nvidia driver version: No CUDA
cuDNN version: No CUDA

Versions of relevant libraries:
[pip] numpy (1.14.5)
[pip] torch (0.4.1)
[pip] torchvision (0.2.1)
[conda] Could not collect

@soumith
Copy link
Member

soumith commented Aug 13, 2018

@KennethAdamMiller you report that your Python version is 2.7, but you are using Python 3.7 (as evidenced by the stack-trace).

We fixed this issue (which affects Python 3.7) in #10271

It was fixed after the 0.4.1 release and will be part of the next release.

@KennethAdamMiller
Copy link
Author

"for both python 2 and 3"

@soumith soumith reopened this Aug 14, 2018
@soumith
Copy link
Member

soumith commented Aug 14, 2018

@KennethAdamMiller sorry for missing that. Can I see a stack-trace for python2? (the python 3.7 issue has been fixed, maybe python 2 has a different issue in your case)

@KennethAdamMiller
Copy link
Author

KennethAdamMiller commented Aug 14, 2018

which python

/usr/local/bin/python

python

Python 2.7.15 (default, Jun 17 2018, 13:05:56)
[GCC 4.2.1 Compatible Apple LLVM 9.0.0 (clang-900.0.39.2)] on darwin
Type "help", "copyright", "credits" or "license" for more information.

import torch
help(torch)
Traceback (most recent call last):
File "", line 1, in
File "/usr/local/Cellar/python@2/2.7.15_1/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site.py", line 446, in call
return pydoc.help(*args, **kwds)
File "/usr/local/Cellar/python@2/2.7.15_1/Frameworks/Python.framework/Versions/2.7/lib/python2.7/pydoc.py", line 1795, in call
self.help(request)
File "/usr/local/Cellar/python@2/2.7.15_1/Frameworks/Python.framework/Versions/2.7/lib/python2.7/pydoc.py", line 1842, in help
else: doc(request, 'Help on %s:')
File "/usr/local/Cellar/python@2/2.7.15_1/Frameworks/Python.framework/Versions/2.7/lib/python2.7/pydoc.py", line 1579, in doc
pager(render_doc(thing, title, forceload))
File "/usr/local/Cellar/python@2/2.7.15_1/Frameworks/Python.framework/Versions/2.7/lib/python2.7/pydoc.py", line 1574, in render_doc
return title % desc + '\n\n' + text.document(object, name)
File "/usr/local/Cellar/python@2/2.7.15_1/Frameworks/Python.framework/Versions/2.7/lib/python2.7/pydoc.py", line 361, in document
if inspect.ismodule(object): return self.docmodule(*args)
File "/usr/local/Cellar/python@2/2.7.15_1/Frameworks/Python.framework/Versions/2.7/lib/python2.7/pydoc.py", line 1143, in docmodule
result = result + self.section('CLASSES', join(contents, '\n'))
File "/usr/local/Cellar/python@2/2.7.15_1/Frameworks/Python.framework/Versions/2.7/lib/python2.7/string.py", line 320, in join
return sep.join(words)
UnicodeDecodeError: 'ascii' codec can't decode byte 0xc2 in position 33224: ordinal not in range(128)

Thanks for being attentive and helping me with it! :D

@soumith
Copy link
Member

soumith commented Aug 14, 2018

in your console, before help(torch), can you run these commands:

import sys  
reload(sys)  
sys.setdefaultencoding('utf8')

Does that fix the issue?

@KennethAdamMiller
Copy link
Author

Yeah that did fix it!

@zou3519 zou3519 added the todo Not as important as medium or high priority tasks, but we will work on these. label Aug 20, 2018
@zou3519
Copy link
Contributor

zou3519 commented Aug 20, 2018

We should probably test and support help(torch) on Python 2

@mruberry
Copy link
Collaborator

mruberry commented Oct 6, 2020

Closing this issue because we no longer support Python 2. Please reopen if it's still relevant.

@mruberry mruberry closed this as completed Oct 6, 2020
@mruberry mruberry removed nightly-announce todo Not as important as medium or high priority tasks, but we will work on these. labels Oct 6, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants