packages

Can I force pip to reinstall the current version?

Can I force pip to reinstall the current version? Question: I’ve come across situations where a current version of a package seems not to be working and requires reinstallation. But pip install -U won’t touch a package that is already up-to-date. I see how to force a reinstallation by first uninstalling (with pip uninstall) and …

Total answers: 9

How to list all installed packages and their versions in Python?

How to list all installed packages and their versions in Python? Question: Is there a way in Python to list all installed packages and their versions? I know I can go inside python/Lib/site-packages and see what files and directories exist, but I find this very awkward. What I’m looking for something that is similar to …

Total answers: 14

How to get the list of options that Python was compiled with?

How to get the list of options that Python was compiled with? Question: You can compile Python in various ways. I’d like to find out with which options my Python was compiled. Concrete use-case: was my Python compiled with readline? I know I can see this by doing “import readline”, but I’d like to see …

Total answers: 5

How to reference to the top-level module in Python inside a package?

How to reference to the top-level module in Python inside a package? Question: In the below hierachy, is there a convenient and universal way to reference to the top_package using a generic term in all .py file below? I would like to have a consistent way to import other modules, so that even when the …

Total answers: 5

Does uninstalling a package with "pip" also remove the dependent packages?

Does uninstalling a package with "pip" also remove the dependent packages? Question: When you use pip to install a package, all the required packages will also be installed with it (dependencies). Does uninstalling that package also remove the dependent packages? Asked By: Hossein || Source Answers: No, it doesn’t uninstall the dependencies packages. It only …

Total answers: 5

Configuring Python to use additional locations for site-packages

Configuring Python to use additional locations for site-packages Question: Is there a way to tell Python about additional site-packages locations without modifying existing scripts? On my CentOS 5.5 server I have a Python 2.7 installation that is installed in /opt/python2.7.2 and there is a site-packages folder at /opt/python2.7.2/lib/python2.7/site-packages. The reason for this is that I …

Total answers: 2

Sibling package imports

Sibling package imports Question: I’ve tried reading through questions about sibling imports and even the package documentation, but I’ve yet to find an answer. With the following structure: ├── LICENSE.md ├── README.md ├── api │   ├── __init__.py │   ├── api.py │   └── api_key.py ├── examples │   ├── __init__.py │   ├── example_one.py │   └── example_two.py └── …

Total answers: 18

Python package name conventions

Python package name conventions Question: Is there a package naming convention for Python like Java’s com.company.actualpackage? Most of the time I see simple, potentially colliding package names like “web“. If there is no such convention, is there a reason for it? What do you think of using the Java naming convention in the Python world? …

Total answers: 7

using __init__.py

using __init__.py Question: I am having difficulty understanding the usage scenarios or design goals of python’s __init__.py files in my projects. Assume that I have ‘model’ directory (refers as a package) which contains the following files __init__.py meta.py solrmodel.py mongomodel.py samodel.py I found two ways of using __init__.py: I have common a definition which needs …

Total answers: 2

How do I write good/correct package __init__.py files

How do I write good/correct package __init__.py files Question: My package has the following structure: mobilescouter/ __init__.py #1 mapper/ __init__.py #2 lxml/ __init__.py #3 vehiclemapper.py vehiclefeaturemapper.py vehiclefeaturesetmapper.py … basemapper.py vehicle/ __init__.py #4 vehicle.py vehiclefeature.py vehiclefeaturemapper.py … I’m not sure how the __init__.py files should be correctly written. The __init__.py #1 looks like: __all__ = [‘mapper’, …

Total answers: 3