2

I am trying to install gpt-2-simple on python 3.5, but when I run the command py -3.5 -m pip install gpt-2-simple, It gives this output:

Collecting gpt-2-simple
  Using cached gpt_2_simple-0.7.1.tar.gz (24 kB)
Collecting regex
  Downloading regex-2020.7.14.tar.gz (690 kB)
     |████████████████████████████████| 690 kB 3.3 MB/s
Collecting requests
  Using cached requests-2.24.0-py2.py3-none-any.whl (61 kB)
Collecting tqdm
  Downloading tqdm-4.48.2-py2.py3-none-any.whl (68 kB)
     |████████████████████████████████| 68 kB 4.5 MB/s
Requirement already satisfied: numpy in c:\users\17_es\appdata\local\programs\python\python35\lib\site-packages (from gpt-2-simple) (1.18.5)
Collecting toposort
  Using cached toposort-1.5-py2.py3-none-any.whl (7.6 kB)
Collecting certifi>=2017.4.17
  Using cached certifi-2020.6.20-py2.py3-none-any.whl (156 kB)
Collecting chardet<4,>=3.0.2
  Using cached chardet-3.0.4-py2.py3-none-any.whl (133 kB)
Collecting urllib3!=1.25.0,!=1.25.1,<1.26,>=1.21.1
  Using cached urllib3-1.25.10-py2.py3-none-any.whl (127 kB)
Collecting idna<3,>=2.5
  Using cached idna-2.10-py2.py3-none-any.whl (58 kB)
Building wheels for collected packages: gpt-2-simple, regex
  Building wheel for gpt-2-simple (setup.py) ... done
  Created wheel for gpt-2-simple: filename=gpt_2_simple-0.7.1-py3-none-any.whl size=23583 sha256=a21616c1d86838d8adf9a06b2ae6b0e9c0c0dbb83016c5c6c5e2356dd8fb6607
  Stored in directory: c:\users\17_es\appdata\local\pip\cache\wheels\15\12\62\827e1180423289d92d6bdfea72981ae5f65b7f27e746f125b1
  Building wheel for regex (setup.py) ... error
  ERROR: Command errored out with exit status 1:
   command: 'C:\Users\17_es\AppData\Local\Programs\Python\Python35\python.exe' -u -c 'import sys, setuptools, tokenize; sys.argv[0] = '"'"'C:\\Users\\17_es\\AppData\\Local\\Temp\\pip-install-njzqms9s\\regex\\setup.py'"'"'; __file__='"'"'C:\\Users\\17_es\\AppData\\Local\\Temp\\pip-install-njzqms9s\\regex\\setup.py'"'"';f=getattr(tokenize, '"'"'open'"'"', open)(__file__);code=f.read().replace('"'"'\r\n'"'"', '"'"'\n'"'"');f.close();exec(compile(code, __file__, '"'"'exec'"'"'))' bdist_wheel -d 'C:\Users\17_es\AppData\Local\Temp\pip-wheel-6txekdc_'
       cwd: C:\Users\17_es\AppData\Local\Temp\pip-install-njzqms9s\regex\
  Complete output (19 lines):
  running bdist_wheel
  running build
  running build_py
  creating build
  creating build\lib.win-amd64-3.5
  creating build\lib.win-amd64-3.5\regex
  copying regex_3\__init__.py -> build\lib.win-amd64-3.5\regex
  copying regex_3\regex.py -> build\lib.win-amd64-3.5\regex
  copying regex_3\_regex_core.py -> build\lib.win-amd64-3.5\regex
  copying regex_3\test_regex.py -> build\lib.win-amd64-3.5\regex
  running build_ext
  building 'regex._regex' extension
  creating build\temp.win-amd64-3.5
  creating build\temp.win-amd64-3.5\Release
  creating build\temp.win-amd64-3.5\Release\regex_3
  C:\Program Files (x86)\Microsoft Visual Studio\2019\Community\VC\Tools\MSVC\14.24.28314\bin\HostX64\x64\cl.exe /c /nologo /Ox /W3 /GL /DNDEBUG /MD -IC:\Users\17_es\AppData\Local\Programs\Python\Python35\include -IC:\Users\17_es\AppData\Local\Programs\Python\Python35\include "-IC:\Program Files (x86)\Microsoft Visual Studio\2019\Community\VC\Tools\MSVC\14.24.28314\include" /Tcregex_3\_regex.c /Fobuild\temp.win-amd64-3.5\Release\regex_3\_regex.obj
  _regex.c
  C:\Users\17_es\AppData\Local\Programs\Python\Python35\include\pyconfig.h(68): fatal error C1083: Cannot open include file: 'io.h': No such file or directory
  error: command 'C:\\Program Files (x86)\\Microsoft Visual Studio\\2019\\Community\\VC\\Tools\\MSVC\\14.24.28314\\bin\\HostX64\\x64\\cl.exe' failed with exit status 2
  ----------------------------------------
  ERROR: Failed building wheel for regex
  Running setup.py clean for regex
Successfully built gpt-2-simple
Failed to build regex
DEPRECATION: Could not build wheels for regex which do not use PEP 517. pip will fall back to legacy 'setup.py install' for these. pip 21.0 will remove support for this functionality. A possible replacement is to fix the wheel build issue reported above. You can find discussion regarding this at https://github.com/pypa/pip/issues/8368.
Installing collected packages: regex, certifi, chardet, urllib3, idna, requests, tqdm, toposort, gpt-2-simple
    Running setup.py install for regex ... error
    ERROR: Command errored out with exit status 1:
     command: 'C:\Users\17_es\AppData\Local\Programs\Python\Python35\python.exe' -u -c 'import sys, setuptools, tokenize; sys.argv[0] = '"'"'C:\\Users\\17_es\\AppData\\Local\\Temp\\pip-install-njzqms9s\\regex\\setup.py'"'"'; __file__='"'"'C:\\Users\\17_es\\AppData\\Local\\Temp\\pip-install-njzqms9s\\regex\\setup.py'"'"';f=getattr(tokenize, '"'"'open'"'"', open)(__file__);code=f.read().replace('"'"'\r\n'"'"', '"'"'\n'"'"');f.close();exec(compile(code, __file__, '"'"'exec'"'"'))' install --record 'C:\Users\17_es\AppData\Local\Temp\pip-record-dieg40uq\install-record.txt' --single-version-externally-managed --compile --install-headers 'C:\Users\17_es\AppData\Local\Programs\Python\Python35\Include\regex'
         cwd: C:\Users\17_es\AppData\Local\Temp\pip-install-njzqms9s\regex\
    Complete output (19 lines):
    running install
    running build
    running build_py
    creating build
    creating build\lib.win-amd64-3.5
    creating build\lib.win-amd64-3.5\regex
    copying regex_3\__init__.py -> build\lib.win-amd64-3.5\regex
    copying regex_3\regex.py -> build\lib.win-amd64-3.5\regex
    copying regex_3\_regex_core.py -> build\lib.win-amd64-3.5\regex
    copying regex_3\test_regex.py -> build\lib.win-amd64-3.5\regex
    running build_ext
    building 'regex._regex' extension
    creating build\temp.win-amd64-3.5
    creating build\temp.win-amd64-3.5\Release
    creating build\temp.win-amd64-3.5\Release\regex_3
    C:\Program Files (x86)\Microsoft Visual Studio\2019\Community\VC\Tools\MSVC\14.24.28314\bin\HostX64\x64\cl.exe /c /nologo /Ox /W3 /GL /DNDEBUG /MD -IC:\Users\17_es\AppData\Local\Programs\Python\Python35\include -IC:\Users\17_es\AppData\Local\Programs\Python\Python35\include "-IC:\Program Files (x86)\Microsoft Visual Studio\2019\Community\VC\Tools\MSVC\14.24.28314\include" /Tcregex_3\_regex.c /Fobuild\temp.win-amd64-3.5\Release\regex_3\_regex.obj
    _regex.c
    C:\Users\17_es\AppData\Local\Programs\Python\Python35\include\pyconfig.h(68): fatal error C1083: Cannot open include file: 'io.h': No such file or directory
    error: command 'C:\\Program Files (x86)\\Microsoft Visual Studio\\2019\\Community\\VC\\Tools\\MSVC\\14.24.28314\\bin\\HostX64\\x64\\cl.exe' failed with exit status 2
    ----------------------------------------
ERROR: Command errored out with exit status 1: 'C:\Users\17_es\AppData\Local\Programs\Python\Python35\python.exe' -u -c 'import sys, setuptools, tokenize; sys.argv[0] = '"'"'C:\\Users\\17_es\\AppData\\Local\\Temp\\pip-install-njzqms9s\\regex\\setup.py'"'"'; __file__='"'"'C:\\Users\\17_es\\AppData\\Local\\Temp\\pip-install-njzqms9s\\regex\\setup.py'"'"';f=getattr(tokenize, '"'"'open'"'"', open)(__file__);code=f.read().replace('"'"'\r\n'"'"', '"'"'\n'"'"');f.close();exec(compile(code, __file__, '"'"'exec'"'"'))' install --record 'C:\Users\17_es\AppData\Local\Temp\pip-record-dieg40uq\install-record.txt' --single-version-externally-managed --compile --install-headers 'C:\Users\17_es\AppData\Local\Programs\Python\Python35\Include\regex' Check the logs for full command output.

As you can see, it says that it successfully built gpt-2-simple, but faild to build regex. I've already tried to find a solution to this, but most answers say to get python3-dev, which is not for windows. How can I fix this problem?

UPDATE: Now when I run the file (which uses gpt_2_simple) there are problems with tensorflow.python.util.compat - it says it has no attribute 'v1', but in the gpt-2-simple files, that line is used extensively. Here is the error:

Traceback (most recent call last):
  File "C:\Users\17_es\OneDrive\Documents\gpt-project\generator.py", line 1, in <module>
    import gpt_2_simple as gpt2
  File "C:\Users\17_es\AppData\Local\Programs\Python\Python35\lib\site-packages\gpt_2_simple\__init__.py", line 1, in <module>
    from .gpt_2 import *
  File "C:\Users\17_es\AppData\Local\Programs\Python\Python35\lib\site-packages\gpt_2_simple\gpt_2.py", line 24, in <module>
    from gpt_2_simple.src import model, sample, encoder, memory_saving_gradients
  File "C:\Users\17_es\AppData\Local\Programs\Python\Python35\lib\site-packages\gpt_2_simple\src\memory_saving_gradients.py", line 13, in <module>
    setattr(tf.compat.v1.GraphKeys, "VARIABLES", "variables")
AttributeError: module 'tensorflow.python.util.compat' has no attribute 'v1'
Elan SK
  • 117
  • 2
  • 11
  • 1
    Does this help answer your question?: https://stackoverflow.com/questions/40018405/cannot-open-include-file-io-h-no-such-file-or-directory – Coder-256 Aug 20 '20 at 17:25
  • @Coder-256 That seemed to fix that particular error, but now I have new errors. Can you please look at the post again for an update? – Elan SK Aug 21 '20 at 04:12
  • 1
    What version of TensorFlow are you using? Update it to the latest version and that should fix the issue. – Coder-256 Aug 21 '20 at 19:09
  • Thanks. I had to use tensorflow 1 instead of 2 because gpt-2-simple isn't compatible with tensorflow 2, but I was using 1.5. Upgrading to 1.14 fixed this issue. – Elan SK Aug 23 '20 at 03:11
  • Glad I could help. Also after a closer look, I would actually recommend using version 1.15.2, since that is the version specified by [`gpt-2-simple`'s `requirements.txt`](https://github.com/minimaxir/gpt-2-simple/blob/92d35962d9aaeadba70e39d11d040f1e377ffdb3/requirements.txt#L1) – Coder-256 Aug 23 '20 at 08:22

0 Answers0