9

I have Python 2.7 as root. I need to install the package "statistics" in Python 3.6, and it is not in the environments of anaconda navigator. How can install "statistics" with conda or pip for a secondary Python environment?

nbro
  • 13,796
  • 25
  • 99
  • 185
Eduardo Bocarruido
  • 330
  • 1
  • 3
  • 7

1 Answers1

13

Create a new Python 3 environment by running:

conda create --name python3 python=3

If you want all the standard anaconda packages installed by default, do:

conda create --name python3 python=3 anaconda

Whenever you need to use python3 run:

activate python3

Then use the command line as normal. So, if you want to install something into your python3 environment, make sure you activate python3 first.

Note that python 3 has it's own statistics module that you may find useful, and this module has been ported to python 2 if you would prefer.

nbro
  • 13,796
  • 25
  • 99
  • 185
Ari Cooper-Davis
  • 3,056
  • 1
  • 25
  • 41
  • 3
    `conda create --name python3 python=3.6 anaconda` - if you want to install a whole Anaconda in python3 (`numpy`, etc.) – Tomasz Gandor Jul 19 '17 at 12:17
  • I have installed the package using a different venv. Now when I try to import that package into my python file I get an error. That module is not defined. – Mauj Mishra Oct 28 '21 at 12:58
  • Hi @MaujMishra - could you ask a new question as `venv`s are not the same as conda environments so behaviour will differ, and we're missing quite a bit of context that we'd need to help you :) – Ari Cooper-Davis Oct 28 '21 at 16:40
  • Hi, Thanks for your reply. I have posted my question here - https://stackoverflow.com/questions/69758907/python-package-installed-using-different-version-of-python-gives-modulenotfounde. – Mauj Mishra Oct 28 '21 at 18:01