Guest User

Emett - Python Followup

a guest
Jul 20th, 2016
300
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. I'm a Python developer and just wanted to add to the question about Python packages.
  2.  
  3. It is always best to install Python packages through pip into a virtualenv and keep the system packages as clean as possible. If you are using Python 3.3+ you can use the built in venv package to setup your virtualenv. This works just like virtualenv but doesn't need a 3rd party package to be installed. If the package does need to be installed system wide such as "uwsgi/gunicorn/salt/ansible/etc..." for "web hosting/management/etc..." you would want to use pip outside of the virtualenv.
  4.  
  5. This will allow you to install a spastic version of the package and update it when you want to not when the package maintainer does and update. You can also use pip to install a package directly from a "website/github/local folder/etc...". If your system also needs to have multiple versions of Python 3 and Python 2.7 you can have a pip for all of them on one system without the risk of stepping on one another "pip-2.7/pip-3.4/pip-3.5/etc.." then when you need a specific version of Python in your script/application you would use the shebang to declare the version at the top of your script/application file.
  6.  
  7.  
  8.  
  9.  
  10. Please find below some examples and links to documentation.
  11.  
  12. venv documentation:
  13.  
  14. https://docs.python.org/3/library/venv.html"
  15.  
  16.  
  17.  
  18. pip documentation:
  19.  
  20. https://pip.pypa.io/en/stable/
  21.  
  22.  
  23.  
  24. pip specific version install:
  25.  
  26. pip install django==1.8
  27.  
  28.  
  29.  
  30. pip install from github repo:
  31.  
  32. pip install -e git+https://github.com/mycroftai/adapt#egg=adapt-parser
  33.  
  34.  
  35.  
  36. pip install from sourceforge:
  37.  
  38. pip install -Iv http://sourceforge.net/projects/mysql-python/files/mysql-python/1.2.2/MySQL-python-1.2.2.tar.gz/download
  39.  
  40.  
  41.  
  42. pip install from folder:
  43.  
  44. pip install -e /path/to/my/package/
  45.  
  46.  
  47.  
  48. pip install only for the current user:
  49.  
  50. pip install --user django
  51.  
  52.  
  53.  
  54. pip update package:
  55.  
  56. pip install -U django
  57.  
  58. pip install --upgrade django
  59.  
  60.  
  61.  
  62. pip install packages in bulk:
  63.  
  64. - You will need a text file with each package on its own line like the example below
  65.  
  66.  
  67.  
  68. requirements.txt file:
  69.  
  70. Django
  71.  
  72. Fabric>=1.2.0
  73.  
  74. Jinja2<=2.5.5
  75.  
  76. PyYAML==3.09
  77.  
  78.  
  79.  
  80. - Once this file has been created you will run the following command
  81.  
  82. - pip install -r requirements.txt
  83.  
  84.  
  85.  
  86. - You can also update with the same file by running the following command
  87.  
  88. - pip install --upgrade -r requirements.txt
  89.  
  90.  
  91.  
  92. Please feel free to reach out to me through email or IRC if you have any questions or if I was unclear on anything. I'm also normally in the "freebsd/freebsd-python/django/django-channels" IRC chat rooms under the name "The-Kid".
RAW Paste Data