Linked Questions
20 questions linked to/from List all the modules that are part of a python package?
590 votes
14 answers
381k views
Reloading submodules in IPython
Currently I am working on a python project that contains sub modules and uses numpy/scipy. Ipython is used as interactive console. Unfortunately I am not very happy with workflow that I am using right ...
340 votes
13 answers
205k views
How to find all the subclasses of a class given its name?
I need a working approach of getting all classes that are inherited from a base class in Python.
183 votes
7 answers
648k views
Python AttributeError: 'module' object has no attribute 'Serial' [duplicate]
I'm trying to access a serial port with Python 2.6 on my Raspberry Pi running Debian. My script named serial.py tries to import pySerial: import serial ser = serial.Serial('/dev/ttyAMA0', 9600) ser....
127 votes
10 answers
175k views
Get a list of all the encodings Python can encode to
I am writing a script that will try encoding bytes into many different encodings in Python 2.6. Is there some way to get a list of available encodings that I can iterate over? The reason I'm trying ...
89 votes
5 answers
61k views
What is __path__ useful for?
I had never noticed the __path__ attribute that gets defined on some of my packages before today. According to the documentation: Packages support one more special attribute, __path__. This is ...
41 votes
5 answers
48k views
List submodules of a python module
How to get the name/list of all submodules of an already imported Python module? (Not the external imported module/packages, just that one in the same folder as module sub-folder). I am using import ...
16 votes
3 answers
23k views
How can I list all packages/modules available to Python from within a Python script?
I have looked around and do not see a solution for this. What I would like to do is get a list of all packages available in Python at run-time. I looked at these: List all the modules that are part ...
8 votes
2 answers
7k views
Something wrong with how I'm bundling rasterio into an executable
Expected behavior and actual behavior. I expected to compile a script using rasterio into an executable using pyinstaller. The script runs fine from within my python environment. However I am not ...
8 votes
1 answer
3k views
Differences in importing modules/subpackages of numpy and Scipy packages
I am using scipy and numpy through Anaconda 2.1.0 distribution. I use Spyder as my Python IDE. When I run import scipy as sp, I can't access the subpackages, such as optimize, linalg, cluster etc. ...
0 votes
1 answer
6k views
How to import a package module from inside a Flask route?
I am migrating an app I have written to the standard Python package format. As I have my app's modules divided over several directories, I used to import these by inserting their respective paths to ...
2 votes
1 answer
1k views
Listing all the modules/subpackages in the NXOpen package
I am trying to follow this post, to list all the modules in the NX Open package: import NXOpen import pkgutil the_string = "" package = NXOpen for importer, modname, ispkg in pkgutil....
0 votes
1 answer
2k views
Importing Modules from Python Package without specifying their names
I am trying to import modules in Python dynamically. That means - I have a Python package with modules inside. Without specifying the modules names, I want to keep a dictionary of each module's name ...
3 votes
1 answer
734 views
Python Finding all packages inside a package, even when in an egg
Given a Python package, how can I automatically find all its sub-packages? I used to have a function that would just browse the file system, looking for folders that have an __init__.py* file in them,...
2 votes
2 answers
253 views
Get modules in a module - Python
I have this structure: project/ sources/ __init__.py source_one.py source_teo.py main.py Then in main.py import sources # Here I'd like to get a list with [source_one,...
2 votes
2 answers
322 views
Checking if a function is Numpy fucntion
I want to check if a passed function is a Numpy function or not. for example: import numpy as np def my_func(passed_func): if passed_func is Numpy function: # Here is the problem print('...