'How to find all imports placed in the code?
Our project contains a lot of import statements inside class/function. That was the way to overcome cycle import issue at the moment. And for now we want to research and fix design issue behind it.
For that purposes I want to find all that places with imports in code.
I have tried to search on "import" in Pycharm IDE and see imports not on the top of the file, but that does not show all this statements.
Then I tried to use pep8, to find all E402 error(Module level import not at top of file), but that does not show all in function impots, that are most interesting
So my question is, how to find all that import that placed in code not in the file header?
Solution 1:[1]
Use pipreqs.
Running pipreqs with the default arguments will generate a requirements.txt for you.
$ pipreqs /home/project/location
Successfully saved requirements file in /home/project/location/requirements.txt
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|---|
| Solution 1 | blackbrandt |
