As you all may know pip is a python package manager and everyone has worked with it to install python libs.
Some of the commands with pip that you may not know about it:
- freeze: output installed packages in requirements format. (you can grep and search for a specific package):
- list: list installed packages:
- show: Show information about installed packages:
Important note for devops: pip by default install a stable version of the package. If you need to install an unstable version of the package (latest version) use
If you want to manage your custom python repository package versions (RC, Alpha, Beta, Stable, etc) add
The important part is
To see list of
https://pypi.python.org/pypi?%3Aaction=list_classifiers
Now you can give versioning like
To see different classifiers see the link
https://pypi.python.org/pypi/Django
#django #pip #pre_release #freeze #package #python #devops
Some of the commands with pip that you may not know about it:
- freeze: output installed packages in requirements format. (you can grep and search for a specific package):
rply==0.7.4
rsa==3.2.3
sasl==0.2.1
scipy==0.13.0b1
- list: list installed packages:
tcpwatch (1.3.1)
telebot (0.0.3)
thrift (0.9.3)
- show: Show information about installed packages:
$ pip show pandas
Name: pandas
Version: 0.17.0
Summary: Powerful data structures for data analysis, time series,and statistics
Home-page: http://pandas.pydata.org
Author: The PyData Development Team
Author-email: pydata@googlegroups.com
License: BSD
Location: /Library/Python/2.7/site-packages
Requires: numpy, python-dateutil, pytz
Important note for devops: pip by default install a stable version of the package. If you need to install an unstable version of the package (latest version) use
--pre
flag to install pre-release package.If you want to manage your custom python repository package versions (RC, Alpha, Beta, Stable, etc) add
classifiers
to your setup.py script like below:setup(...,
classifiers=[
'Development Status :: 4 - Beta',
'Environment :: Console',
'Environment :: Web Environment',
'Intended Audience :: End Users/Desktop',
'Intended Audience :: Developers',
'Intended Audience :: System Administrators',
'License :: OSI Approved :: Python Software Foundation License',
'Operating System :: MacOS :: MacOS X',
'Operating System :: Microsoft :: Windows',
'Operating System :: POSIX',
'Programming Language :: Python',
'Topic :: Communications :: Email',
'Topic :: Office/Business',
'Topic :: Software Development :: Bug Tracking',
],
)
The important part is
Development Status :: 4 - Beta
, which for stable release you would use Development Status :: 5 - Production/Stable
.To see list of
pypi
Development Status values read from the below link:https://pypi.python.org/pypi?%3Aaction=list_classifiers
Now you can give versioning like
Django 2.0b1
(for pre release) and Django 1.11.6
for stable release.To see different classifiers see the link
Django
link below to learn more:https://pypi.python.org/pypi/Django
#django #pip #pre_release #freeze #package #python #devops
Installation of Django
If you have not yet installed django on your system, install it using the below command:
After installation you can check the validity of the
What does
To see list of
That's it! Welcome to the
#python #django #installation #pip #django_part1
If you have not yet installed django on your system, install it using the below command:
$ sudo pip install django
Password:
Collecting django
Downloading Django-1.11.6-py2.py3-none-any.whl (6.9MB)
100% |████████████████████████████████| 7.0MB 174kB/s
Requirement already satisfied: pytz in /Library/Python/2.7/site-packages (from django)
Installing collected packages: django
Successfully installed django-1.11.6
After installation you can check the validity of the
Django
installation:$ python -m django --version
1.11.6
What does
-m
do in the above command:-m module-name
Searches sys.path for the named module and runs the corresponding .py file as a script.
To see list of
django-admin
subcommands:$ django-admin help
Type 'django-admin help <subcommand>' for help on a specific subcommand.
Available subcommands:
[django]
check
compilemessages
createcachetable
dbshell
diffsettings
dumpdata
flush
inspectdb
loaddata
makemessages
makemigrations
migrate
runserver
sendtestemail
shell
showmigrations
sqlflush
sqlmigrate
sqlsequencereset
squashmigrations
startapp
startproject
test
testserver
Note that only Django core commands are listed as settings are not properly configured (error: Requested setting INSTALLED_APPS, but settings are not configured. You must either define the environment variable DJANGO_SETTINGS_MODULE or call settings.configure() before accessing settings.)
That's it! Welcome to the
Django
world. :)#python #django #installation #pip #django_part1
To install your python module you need a setup.py file inside of your project. The content of the setup.py can be something like below:
Now if you want to install it on your machine as a package just:
If you want to upload it into your python repository:
NOTE: you should be in the root of your project before running the previous command.
my_repo server should be declared inside of
If you want to install something from your repository via pip you have to provide the
NOTE: you can put inside of an ENV variable in OS to access it better and in more readable way.
#python #setuppy #setup #package #pypi #private_repo #pypirc #pip #install
setup(name=PROJECT_NAME,
version=PROJECT_VERSION,
description=PROJECT_DESCRIPTION,
long_description=PROJECT_LONG_DESCRIPTION,
author='Ali',
author_email='info@ali.com',
url='http://www.ali.com/',
license='SOMETHING',
entry_points=PROJECT_ENTRY_POINTS,
classifiers=[],
keywords='',
packages=find_packages(exclude=['ez_setup', 'examples', 'tests']),
include_package_data=True,
namespace_packages=[],
install_requires=['LIST', 'OF', 'REQUIREMENTS'],
zip_safe=False,
test_suite='nose.collector')
Now if you want to install it on your machine as a package just:
python setup.py install
If you want to upload it into your python repository:
python setup.py sdist upload -r my_repo
NOTE: you should be in the root of your project before running the previous command.
my_repo server should be declared inside of
~/.pypirc
:[distutils]
index-servers =
my_repo
[my_repo]
repository: http://pypi.repo.my_host.com:5000
username: username
password: password
If you want to install something from your repository via pip you have to provide the
extra-index-url
argument:--extra-index-url http://username:password@pypi.repo.my_host.com:5000 --trusted-host pypi.repo.my_host.com
NOTE: you can put inside of an ENV variable in OS to access it better and in more readable way.
#python #setuppy #setup #package #pypi #private_repo #pypirc #pip #install
http://pygments.org/
This is a syntax highlighter that creates permanent link for your code in a variety of languages including
#python #pip #syntax_highlighter #highlighter #pygments
This is a syntax highlighter that creates permanent link for your code in a variety of languages including
python
in the provided link.#python #pip #syntax_highlighter #highlighter #pygments
Some useful
#python #pip #list #freeze #show #info #search
pip
(python package manager) command:show
: used to know specific information about a module installed on your system:$ pip show requests
Name: requests
Version: 2.13.0
Summary: Python HTTP for Humans.
Home-page: http://python-requests.org
Author: Kenneth Reitz
Author-email: me@kennethreitz.com
License: Apache 2.0
Location: /Library/Python/2.7/site-packages
Requires:
search
: used to search a python package on pypi.python.org
:$ pip search "suds"
suds-aop (0.6.1) - Lightweight SOAP client (aop's fork)
...
...
...
NOTE:
the above list is truncated.list
: list installed packages.pip list
NOTE:
you can grep on pip list
to see if a specific package is installed or check its version:pip list | grep "requests"
freeze
: this command does the the same task as list
, but its output can be placed inside of the requirements.txt
.uninstall
: remove a package from your system:pip uninstall requests
#python #pip #list #freeze #show #info #search
If you run python using
This error says that the plugin is not loaded. This error happens when you install uwsgi using pip. Distros should package uWSGI in a modular way, with each feature as a plugin. But when you install using language specific ways (pip, gem...) the relevant language is embedded, so you do not need to load the plugin.
#python #uwsgi #pip
uwsgi
you may get an error like below:open("./python_plugin.so"): No such file or directory [core/utils.c line 3321]
!!! UNABLE to load uWSGI plugin: ./python_plugin.so: cannot open shared object file: No such file or directory !!!
This error says that the plugin is not loaded. This error happens when you install uwsgi using pip. Distros should package uWSGI in a modular way, with each feature as a plugin. But when you install using language specific ways (pip, gem...) the relevant language is embedded, so you do not need to load the plugin.
#python #uwsgi #pip
Babel:
Babel is an integrated collection of utilities that assist in internationalizing and localizing Python applications, with an emphasis on web-based applications.
pip install Babel
More information:
- http://babel.pocoo.org/en/latest/index.html
#python #pocoo #pip #babel #internationalization #localization