0

Some time ago, I installed Django (with pip) and had some trouble doing some things with it because I didn't create a virtual environment (at least that's what it looked like). That time I was recommended to install it with conda since I use Anaconda's spyder.

Now, with a new Windows installation, I'm trying to start to learn Django again, but I'm confused as to whether I should use conda or pip to install it. I read here What is the difference between pip and conda? that they cannot be used interchangeably, but I'm not sure what that means.

If I install Django and some other packages with conda, does that mean I have to do something extra to then install some package with pip? Say, if there is a package conda can't install, as I read in that same question.

They said that conda "also creates a virtual environment`, does that mean that every time I install something with it, it is not being installed globally and besides the installation I also set up its virtual environment?

Thank you very much.

TheSprinter
  • 338
  • 1
  • 12
  • `pip` merely installs python packages, whereas Anaconda manages entire python environments, as well as installs packages. You can install python packages in a conda environment with either `pip` or `conda`, but you can't really switch between python versions and environments with `pip` – bug_spray May 29 '20 at 10:45
  • @bug_spray To avoid repeating the same comment, please have a look at the one I added to the answer. – TheSprinter May 29 '20 at 11:09
  • Not sure which comment you're referring to, but "they can't be used interchangeably" means "they're not the same thing." – bug_spray May 29 '20 at 14:37

1 Answers1

2

Installing a conda package without activating an environment installs the package to conda's default virtual environment, called base. I'd recommend you read up on how virtual environments work and prevent package conflicts.

You can install a python package in a conda environment using pip. Just activate that environment and use pip install package_name as you would normally do. You should however avoid this by first making sure the package is unavailable in any of the conda repositories.

droptop
  • 1,372
  • 13
  • 24
  • Thank you very much. So the recommendation would be to install Django with conda and activate a virtual environment for each project? With the initial project being the one I'll use to learn the first things. – TheSprinter May 29 '20 at 11:08
  • @TheSprinter exactly. – droptop May 29 '20 at 11:44
  • Thank you. By the way, I'm seeing in the Anaconda documentation that to install a package, you use `conda install package-name`, but in the page for Django in the Anaconda repository, I see `conda install -c anaconda django`. What's with the `-c anaconda`? – TheSprinter May 29 '20 at 11:52
  • `-c` specifies a channel from which the package is to be installed. Checkout https://docs.conda.io/projects/conda/en/latest/user-guide/tasks/manage-channels.html – droptop May 29 '20 at 12:03