To install a package, use the 'install' command. Instead of executing programs under the system-default Python environments, the virtualenv's Python programs are being executed. If you take a look at the content of the folder 'python-workspace/bin', you will see a list of executable programs such as 'python', 'pip' and 'easy_install', etc. % python # enter an interpreter shell by executing the current virtual python program under 'python-workspace/bin/python' bin/activate # activate the virtualenv 'python-workspace' Once you have set up the new virtualenv under 'python-workspace', you need to activate it so that the Python environment in the current shell will transition into the virtualenv: # Create a virtual environment under the folder 'python-workspace' If your current Python environment does not contain any package manager, you could download one Python file from here and run it: % virtualenv python-workspace # create a virtual environment under the folder 'python-workspace' # easy_install is the default package manager in CPython To install and set up pip and virtualenv, run the following commands: One advantage of sandboxing your Python environment is that you can effortlessly test your code under different Python versions and package dependencies without switching between virtual machines. Instead of modifying the global Python environment, virtualenv allows a programmer to setup independent Python contexts that are similar to separate sandboxes. Virtualenv is a tool for sand-boxing Python environments. Setting up virtualenv and pip to perform simple operations It's simple to define sets of requirements, thus easy to replicate a set of packages across different environments.This is a huge advantage over easy_install, which requires the programmer to manually uninstall packages. For example, you could install a Python package directly from a GitHub repository if it's setup properly. Native support for other version control systems.Packages can be installed as flat modules, which makes library-code debugging much easier than egg archives.For example, the reason why a package was required is recorded for future reference. It keeps record of why actions are performed.Output information is pre-processed, so it's more useful than eccentric messages.All packages are downloaded before installation to prevent partial (thus broken) installation.From a high-level point of view, pip has the following advantages over easy_install: It is written to replace an older tool called easy_install. Like many useful programming ecosystems, Python provides a powerful and easy-to-use package management system called pip. Last Updated: Tuesday 17 th September 2013 Using pip to Manage Python Packages
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |