Top "Python-import" questions

For questions about importing modules in Python

Import a module with parameter in python

Is it possible to import a module with some parameter in python ? All I mean by parameter is that there …

python python-import python-module pymc mcmc
pyspark import user defined module or .py files

I built a python module and I want to import it in my pyspark application. My package directory structure is: …

python apache-spark pyspark python-import python-module
How to properly use relative or absolute imports in Python modules?

Usage of relative imports in Python has one drawback, you will not be able to run the modules as standalones …

python module packages python-module python-import
Flask "Error: The file/path provided does not appear to exist" although the file does exist

I use export FLASK_APP=flask_app and then do flask run but I get the error: Error: The file/…

python flask python-import file-not-found
ImportError: No module named app

I working with Flask-Testing and make file test_app.py to test But I got this error File "test_app.…

python flask python-import flask-testing
Why does Python's __import__ require fromlist?

In Python, if you want to programmatically import a module, you can do: module = __import__('module_name') If you want …

python python-import
How to test or mock "if __name__ == '__main__'" contents

Say I have a module with the following: def main(): pass if __name__ == "__main__": main() I want to write a …

python unit-testing testing mocking python-import
Does python optimize modules when they are imported multiple times?

If a large module is loaded by some submodule of your code, is there any benefit to referencing the module …

python python-import
Good or bad practice in Python: import in the middle of a file

Suppose I have a relatively long module, but need an external module or method only once. Is it considered OK …

python python-import
ImportError: cannot import name 'QtCore'

I am getting the below error with the following imports. It seems to be related to pandas import. I am …

python anaconda python-import qtcore