首页 > 解决方案 > Package Management - Pip / Conda / Virtualenv

问题描述

I have been looking for an answer and reading about the following question but I still do not understand a theoretical aspect of using pip and conda on the same computer. Maybe someone can help me. The process I follow when I start a project is:

  1. git init
  2. create virtual environment (I use "pyenv virtualenv")
  3. check the installed packages doing "pip list" and "conda list"

Here is where I do not understand what is happening, "pip list" basically tells me I only have installed: "pip" and "setuptools"

I like this.

But conda imports everything I have outside the virtual environment (which is more than 50 packages), this I do not like so much. Whenever I start a project and try to use, for example, "pandas" it directly uses it taking the conda package so I do not have to install it. While this is convenient to avoid wasting time I thought that virtual environments actually wanted to avoid this.

I am a rookie but I have read in several places that if you create a project it is best practice to then do "pip freeze > requirements.txt" which then creates the list of packages and their version in case you want to replicate it in the future. The problem is that since my system is using the packages in conda they are not pulled to the pip freeze list. This entails that in the future I will not know what pandas package I used.

Questions:

  1. Is the scenario clear?
  2. What is recommended in this case? Should I start using conda only? (I personally like starting from 0 every project and building from there)

P.S.: when I install a package with pip it normally installs everything that is required to make that package work (which tend to be many packages), but when I look at the requirements.txt of projects on GitHub these are very short lists (example). What is best practice here? should I only put in my requirements.txt the one I installed o put the whole list that gets installed together?

标签: pythonpipvirtualenvcondapyenv

解决方案


推荐阅读