Find package version
To find the version of a specific package, simply run the following snippet:
import pkg_resources
pkg_resources.get_distribution("package_name").version
Or you can directly get the package info by running the following terminal command:
pip show
Share a python script in compiled form
If you want to share your python script without sharing also the source you can compile it to .pyc version with the following command.
python -m compileall .
If the directory name (the current directory here, denoted with ".") is omitted, the module compiles everything found on sys.path.
Solving compilation errors when installing new python packages
We must admit that it's a bit clumsy when you're about to install additional Python packages in a windows system. The most preferable way to do this is by using pip install command. But sometimes, if you have ever tried to install some packages with either pip install or downloading the source package and running setup.py install, you may have received the following message:
error: Unable to find vcvarsall.bat
This means that, these packages require compiling and Python searches for an installed Visual Studio compiler. To overcome this you can force Python to use a Visual Studio by setting the correct path in VS90COMNTOOLS environment variable before executing pip install command or calling the correspoding setup.py by executing the correspoding terminal command:
set VS90COMNTOOLS = %VS100COMNTOOLS% # If you have Visual Studio 2010 installed
set VS90COMNTOOLS = %VS110COMNTOOLS% # If you have Visual Studio 2012 installed