Reputation: 11734
I am relatively new to Python and am using it in a very small XML parsing script. I have become totally confused as to the various Python versions, and their package managers.
I am using Ubuntu 13.10, which appears to come with both Python2.7 and Python3.3 pre-installed from a fresh installation.
Outside of a virtualenv I have access to both versions from the prompt:
>which python
/usr/bin/python
>which python2
/usr/bin/python2
>which python3
/usr/bin/python3
the first two are symlinked to the same python2.7 binary and the third to a python3.3 binary. Which all makes perfect sense.
I also understand that python3.3 comes with pyvenv for creating virtualenvs for python3.3
>pyvenv-3.3 mynewproject
creates a new virtual environment with a bin directory and a "self-contained" python3.3 interpreter and etc. To use this environment I just:
>source <path-to-mynewproject>/bin/activate
All fine and understood. Makes perfect sense. Now though comes the confusion. Do I use easy_install? Pip? Setup.py? Distribute? What are all these myriad package managers? Where do I get them? Do they work with Python2.7 or Python3.3? Or Both? Which ones will work in my new virtualenv? Do I care?
In short, given that I am only ever going to be doing Python3.3+ development, but given also that I don't want to break my system which undoubtedly needs Python2.7 packages, what is the canonical (best, approved, supported) way for me to do package management.
Seriously, what the heck? Totally confused.
Thanks for all your forth-coming assistance.
Upvotes: 2
Views: 260
Reputation: 13600
pip
and easy_install
are both package managers you can use both of them but I prefer pipsetup.py
is just a script for distutils, pip
and easy_install
both use setup.py
to install packages.If you run your python in virtualenvs, it will prevent you from uninstalling or updating packages that will break your system. Then the choice between pip and easy_install isn't so clear. In theory pip
is newer but for some reasons the way they install packages might work on pip and not on easy_install. These problems happen when you have to deal with native libraries that have to be compiled... It's hard to say which one is better but the one that works should do the trick since they are installing package in the same directory anyway.
There is no real need to install packages with setup.py
unless they aren't available in pypi
. pip
also happens to install packages with setup.py
if you pass it the directory where it is located.
If you make a package, make sure it's installable with distutils using setup.py
. Then you can release it to pypi
.
Also, as I know many tutorials aren't using virtualenvs and might even write inside their tutorials things like:
sudo pip install ..
sudo easy_install ..
Note that if you're using virtualenv you should never have to use sudo, and if you do use sudo, it's possible that it will install the package system wide as it won't be runned from the user in virtualenv but from root.
Suggested reading by Lukas Graf : http://guide.python-distribute.org/introduction.html#the-packaging-ecosystem
Upvotes: 4