bndr / pipreqs

pipreqs - Generate pip requirements.txt file based on imports of any project. Looking for maintainers to move this project forward.
Apache License 2.0
6.11k stars 383 forks source link

Problems with Python 3.11 #333

Open mickdewald opened 1 year ago

mickdewald commented 1 year ago

I upgraded my project to Python 3.11 und pipreqs stopped working.

Usually, I call it via REST API call just to list my libs (for dev and debug purposes) and with Python 3.11 it just hangs and nothing happens. When I run it in debug mode via ./venv/bin/pipreqs --debug I got the following output

❯ ./venv/bin/pipreqs --debug
DEBUG: Found packages: {'urllib3_secure_extra', 'optparse', 'curio', 'PySide2', 'mmap', 'csv', 'python_anticaptcha', '_cffi_backend', 'bit_generator', 'mypy_extensions', '__pypy__', 'trollius', 'pythoncom', 'brotlicffi', 'copy_reg', 'boto3', 'wsaccel', 'pyximport', 'ConfigParser', 'tempfile', 'zstandard', 'calendar', 'kombu', 'UserList', 'uwsgi', 'xlwt', 'fastparquet', 'tensorflow', 'org', 'msvcrt', '_winreg', 'ctags', 'pickle5', 'polling', 'asynctest', 'trio_typing', 'botocore', 'shutil', 'win32console', 'mpl_toolkits', 'aiodns', 'coverage', 'pdb', 'anydbm', 'tkinter', 'socketserver', 'fnmatch', 'win32process', 'railroad', 'olefile', 'tables', 'contextlib', 'number', '_frozenlist', 'locale', 'gc', 'colorsys', 'cchardet', 'sqlite3', 'ipaddress', '_multiarray_umath', 'pyquery', 'lockfile', 'urllib2', 'polling2', 'winreg', 'socksio', '_thread', 'mtrand', '_cmsgpack', '_testbuffer', 'reprlib', 'PyQt5', 'stringprep', 'numpy_api', 'dis', 'unicodedata2', 'curses', 'cycler', '_setuplibev', 'requirementslib', 'stat', 'orjson', 'cext', '_websocket', 'aio_pika', 'multiprocessing', 'simple_websocket', 'xarray', 'argparse', 'dbm', '_philox', 'base64', 'speedups', 'cStringIO', 'grp', 'imp', 'gmpy', 'pox', 'xdrlib', 'keyring', 'readline', '__future__', 'mimetools', 'pyczmq', 'v8eval', 'watchdog', 'StringIO', 'ast', 'tracemalloc', 'fcntl', 'slack_sdk', 'ntlm', 'monotime', 'pydoc', 'mem_policy', 'pkgutil', '_brotli', 'Tkinter', 'win32pdh', 'math', 'h2', 'IPython', 'dummy_threading', 'trove_classifiers', 'pipes', 'aiocontextvars', 'tabulate', 'UserDict', 'tokio', 'url_parser', 'mimetypes', 'tarfile', 'pymongo_auth_aws', 'win32con', 'numexpr', 'PyQt4', 'winkerberos', 'odf', 'netrc', 'win32api', 'xmlrpclib', 'cgi', 'testsuite', '_typeshed', 'objgraph', '_cffi', 'hypothesis', 'ipywidgets', 'keyword', 'array_interface_testing', 'sphinx', '_ctypes', 'py_compile', 'service_identity', 'atexit', '_proxy_steerable', 'zipfile', 'ordereddict', '_quoting_c', 'kubernetes_validate', 'Queue', '_abcoll', 'UserString', 'PyQt6', 'weakref', 'termios', 'typed_ast', 'Foundation', 'plistlib', 'runpy', 'shelve', '_aix_support', '_continuation', 'fsspec', 'PySide6', 'copy', 'rlcompleter', 'SimpleHTTPServer', 'enchant', 'statsmodels', 'scipy', 'code_generators', 'webbrowser', 'errno', 'blinker', 'adal', 'pip_api', 'qtpy', 'sympy', 'selenium', 'Numeric', 'numarray', 're', 'defusedxml', 'psycopg2', 'argon2pure', 'operator', 'tokenize', 'funcsigs', 'wsproto', 'bisect', '_multidict', 'dummy_thread', 'traitlets', 'xlrd', '_csv', 'gi', 'aioredis', 'marshal', 'gettext', '_umath_tests', 'uuid', '_osx_support', '_http_parser', 'pstats', 'PySide', 'zipimport', 'copyreg', 'getopt', 'kafka', 'openpyxl', 'binascii', 'paramiko', 'encodings', 's3fs', 'heapq', 'syslog', 'kerberos', 'xlsxwriter', 'timeit', 'codecs', 'shlex', 'struct', 'sklearn', 'pandas_datareader', 'unittest2', 'HTMLParser', 'jnius', 'snappy', '_pcg64', '_rust_notify', 'bcryptor', 'geventwebsocket', 'BeautifulSoup', 'pylama', 'codeop', '_device', 'fastpbkdf2', 'urlparse', 'pyu2f', '_generator', 'docutils', 'setuptools_scm', 'lib2to3', '_dummy_thread', 'lzma', 'wmi', 'simplejson', 'java', 'pymongocrypt', 'unicodedata', '_string', 'oauth2client', 'matplotlib', 'outcome', 'argcomplete', 'AppKit', 'cmath', 'pprint', '_pyio', '_frozen_importlib_external', 'urllib', 'genapi', '_frozen_importlib', 'mutex', 'win32com', 'com', 'tomllib', 'fractions', 'htmlentitydefs', 'cftime', 'disco', 'watchgod', 'ctypes', 'cPickle', '__builtin__', 'ttk', 'secrets', 'zlib', 'truststore', 'gmpy2', 'getpass', 'pyxlsb', '_wrappers', 'bdb', '_multibytecodec', 'python_socks', '_greenlet', 'wsgiref', 'difflib', 'numpy_distutils', 'BaseHTTPServer', '_mt19937', 'hashlib', 'tty', 'email', '_sfc64', 'auth_tests', 'selectors2', 'posixpath', 'pylab', 'idna_ssl', 'Cython', 'cares', 'linecache', 'concurrencytest', 'win32_setctime', 'pymysql', 'PyInstaller', 'compileall', 'fileinput', '_collections_abc', 'cProfile', 'ntpath', '_speedups', 'sys', '_psutil_windows', 'OpenSSL', 'gunicorn', '_ufunc', 'kazoo', 'sets', 'pty', 'textwrap', 'asgiref', 'flake8', 'dl', 'pexpect', 'bz2', '_setuputils'}
DEBUG: Found imports: __builtin__, __pypy__, _abcoll, _brotli, _cffi, _cffi_backend, _cmsgpack, _continuation, _device, _frozenlist, _generator, _greenlet, _http_parser, _mt19937, _multiarray_umath, _multidict, _pcg64, _philox, _proxy_steerable, _psutil_windows, _quoting_c, _rust_notify, _setuplibev, _setuputils, _sfc64, _speedups, _typeshed, _ufunc, _umath_tests, _websocket, _winreg, _wrappers, adal, aio_pika, aiocontextvars, aiodns, aioredis, anydbm, AppKit, argcomplete, argon2pure, array_interface_testing, asana_kazoo, asgiref, asynctest, auth_tests, BaseHTTPServer, bcryptor, BeautifulSoup, bit_generator, blinker, boto3, botocore, brotlicffi, cares, cchardet, cext, cftime, code_generators, com, concurrencytest, ConfigParser, copy_reg, coverage, cPickle, cStringIO, ctags, ctypes_snappy, curio, cycler, Cython, defusedxml, disco, dl, docutils, dummy_thread, fastparquet, fastpbkdf2, flake8, Foundation, fsspec, funcsigs, genapi, gevent_websocket, gi, gmpy, gmpy2, gunicorn, h2, htmlentitydefs, HTMLParser, hypothesis, idna_ssl, ipython, ipywidgets, java, jnius, kafka, kerberos, keyring, kombu, kubernetes_validate, lockfile, matplotlib, mem_policy, mimetools, monotime, mpl_toolkits, mtrand, mutex, mypy_extensions, ntlm, numarray, number, Numeric, numexpr, numpy_api, numpy_distutils, oauth2client, objgraph, odfpy, olefile, openpyxl, ordereddict, org, orjson, outcome, pandas_datareader, paramiko, pexpect, pickle5, pip_api, polling, polling2, pox, psycopg2, pyczmq, pyenchant, PyInstaller, pylab, pylama, pymongo_auth_aws, pymongocrypt, pymysql, pyOpenSSL, PyQt4, PyQt5, PyQt6, pyquery, PySide, PySide2, PySide6, python_anticaptcha, python_socks, pythoncom, pyu2f, pyxlsb, qtpy, Queue, railroad, requirementslib, s3fs, scikit_learn, scipy, selectors2, selenium, service_identity, sets, setuptools_scm, simple_websocket, SimpleHTTPServer, simplejson, slack_sdk, socksio, speedups, Sphinx, statsmodels, StringIO, sympy, tables, tabulate, tensorflow, testsuite, Tkinter, tokio, tomllib, traitlets, trio_typing, trollius, trove_classifiers, truststore, ttk, typed_ast, unicodedata2, unittest2, url_parser, urllib2, urllib3_secure_extra, urlparse, UserDict, UserList, UserString, uwsgi, v8eval, watchdog, watchgod, win32_setctime, win32api, win32com, win32con, win32console, win32pdh, win32process, winkerberos, wmi, wsaccel, wsproto, xarray, xlrd, xlsxwriter, xlwt, xmlrpclib, zstandard
DEBUG: Getting packages information from Local/PyPI
DEBUG: Starting new HTTPS connection (1): pypi.python.org:443
DEBUG: https://pypi.python.org:443 "GET /pypi/__builtin__/json HTTP/1.1" 301 122
DEBUG: Starting new HTTPS connection (1): pypi.org:443
DEBUG: https://pypi.org:443 "GET /pypi/-builtin-/json HTTP/1.1" 404 24
DEBUG: Package __builtin__ does not exist or network problems
DEBUG: Starting new HTTPS connection (1): pypi.python.org:443
DEBUG: https://pypi.python.org:443 "GET /pypi/__pypy__/json HTTP/1.1" 301 122

... (the http calls continue for some time)

Is this a bug, or do I make a mistake? It worked perfectly with Python 3.10

I can provide more information if needed

linroex commented 1 year ago

trying to ignore dist folder (generated by PyInstaller), I has same issue and I found is dist folder

pipreqs --ignore dist/,venv/,__pycache__ --print
mickdewald commented 1 year ago

I can try that. For now, I am using an alternative library (pigar)

trying to ignore dist folder (generated by PyInstaller), I has same issue and I found is dist folder

pipreqs --ignore dist/,venv/,__pycache__ --print
momift commented 11 months ago

I can try that. For now, I am using an alternative library (pigar)

trying to ignore dist folder (generated by PyInstaller), I has same issue and I found is dist folder

pipreqs --ignore dist/,venv/,__pycache__ --print

Hi Micktg, your solution is the best

Thank you