Skip to content

Commit

Permalink
[pytorch] Add error when PyTorch used with Python 2 (pytorch#36151)
Browse files Browse the repository at this point in the history
Summary:
Pull Request resolved: pytorch#36151

Python 2 has reached end-of-life and is no longer supported by PyTorch. To avoid confusing behavior when trying to use PyTorch with Python 2, detect this case early and fail with a clear message.  This commit covers `import torch` only and not C++  for now.

Test Plan: waitforsandcastle

Reviewed By: dreiss

Differential Revision: D20894381

fbshipit-source-id: a1073b7a648e07cf10cda5a99a2cf4eee5a89230
  • Loading branch information
orionr authored and facebook-github-bot committed Apr 8, 2020
1 parent f99e637 commit 38849e1
Showing 1 changed file with 4 additions and 0 deletions.
4 changes: 4 additions & 0 deletions torch/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,10 @@
import sys
import platform
import ctypes

if sys.version_info < (3,):
raise Exception("Python 2 has reached end-of-life and is no longer supported by PyTorch.")

from ._utils import _import_dotted_name
from ._utils_internal import get_file_path, prepare_multiprocessing_environment, \
USE_RTLD_GLOBAL_WITH_LIBTORCH
Expand Down

0 comments on commit 38849e1

Please sign in to comment.