0
votes

I'm a newbie following tutorials online. I'm having real troubles with PyCharm, Python and Anaconda. Two questions:

(1) when I 'pip install x' in CMD, they only seem to install in Anaconda site packages, not the Python one. Do I need to install in both to have access in both?

(2) I thought the reason to have Anaconda was because it came with packages like numpy. When I 'import numpy' in PyCharm in either Conda or Python39 environment, it says module not found and I have to install it anyway. What's the point? I created a PyCharm Conda environment for that reason to use the packages?

I have C:...\anaconda3, .\scripts & .\bin in system PATH variables, and C:...\Python39 & .\bin in user PATH variables.

I'd be really grateful if someone could clarify things. Thanks.

INPUT-> C:\Users\tk20blue>where pip
C:\Users\tk20blue\anaconda3\Scripts\pip.exe
C:\Users\tk20blue\AppData\Local\Programs\Python\Python39\Scripts\pip.exe

INPUT-> C:\Users\tk20blue>where python
C:\Users\tk20blue\anaconda3\python.exe
C:\Users\tk20blue\AppData\Local\Programs\Python\Python39\python.exe
C:\Users\tk20blue\AppData\Local\Microsoft\WindowsApps\python.exe

INPUT-> C:\Users\tk20blue>where anaconda
C:\Users\tk20blue\anaconda3\Scripts\anaconda.exe

INPUT-> C:\Users\tk20blue>python --version
Python 3.8.5

INPUT -> C:\Users\tk20blue>py
Python 3.9.0 (tags/v3.9.0:9cf6752, Oct  5 2020, 15:34:40) [MSC v.1927 64 bit (AMD64)] on win32
Type "help", "copyright", "credits" or "license" for more information.

3

3 Answers

1
votes

You have two different python installs running at the same time. Anaconda is python. When you installed it after installing python, you essentially have two now. You should uninstall Python, and reinstall Anaconda.

I really like the Anaconda environment and you should really look at using conda to install most/all of your packages.

Here is a great tutorial: https://www.datacamp.com/community/tutorials/installing-anaconda-windows

0
votes

conda allows you to create separate Python environments for different projects. This means you can have different packages, or even different versions of packages, for each project. To use a particular conda environment in PyCharm, you have to configure PyCharm to use that environment. I suggest checking out the PyCharm documentation for more details about how to do that.

0
votes

Setting up Anaconda + Pycharm on Windows works like a charm. Maybe the following helps:

1. Installation

  • install Anaconda from www.anaconda.com
  • add Anaconda to your path (offered during installation), e.g. C:\ProgramData\Anaconda3\Scripts

2. Create a Conda Environment (Python+Packages Sandbox)

  • $ conda create -n <env_name> python=<python_version>: create a new Python <python_version> conda environment (e.g. <env_name> = foobar and <python_version>=3.8)

3. Activate and add packages to your environment

  • $ activate <env_name>: activate environment
  • $ pip install <foo_package>: install via pip
  • $ conda install <bar_package>: further conda-offered packages

Remark: activate doesn't work for me with git-bash, but with cmd or powershell

Remark: You can repeat these steps whenever you want to add new packages to your conda environment.

4. Use the environment for your project in PyCharm

  • Open an existing or new PyCharm project
  • Select your conda environment via File > Setting > Project: <your_project> > Python Interpreter e.g. by setting it to C:\ProgramData\Anaconda3\envs\<env_name>\python.exe

Further useful conda commands

  • $ deactivate: deactivate environment
  • $ conda update --all: update all Anaconda packages
  • $ conda install python=3.8: upgrade to a new major Python version (in this case 3.8)
  • $ conda info --envs: list all existing conda environments lazysheets
  • $ conda env export > environment.yaml: export your active environment dependencies
  • $ conda env create -f environment.yaml: create conda environment from environment.yaml