Reputation: 45
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.
Upvotes: 0
Views: 412
Reputation: 2180
Setting up Anaconda + Pycharm on Windows works like a charm. Maybe the following helps:
C:\ProgramData\Anaconda3\Scripts
$ 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
)$ activate <env_name>
: activate environment$ pip install <foo_package>
: install via pip$ conda install <bar_package>
: further conda-offered packagesRemark: 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.
File > Setting > Project: <your_project> > Python Interpreter
e.g. by setting it to C:\ProgramData\Anaconda3\envs\<env_name>\python.exe
$ 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
Upvotes: 0
Reputation: 83517
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.
Upvotes: 0
Reputation: 3907
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
Upvotes: 2