-1

I'm fairly new to Python but not programming and I have some questions about the Python ecosystem if someone could shed some light for me. Most of my python experience has been on a windows computer. I installed python3 and pycharm and had no questions what so ever. Then, I decided to get some work done on my MacBook and needed to install python 3 opposed to python 2 currently installed. That's where I fell down the rabbit hole.

I went to the python website and installed python 3. Then someone recommended I install it using HomeBrew. So I don't really understand Homebrew. My understanding is, it's a package manager for macOS. Basically it's like what pip is to python, what homebrew is to macOS? If I were just to install python 3 without homebrew I could call it in terminal as Python3 asdfasdf and it would work fine no? Also, what is all this PATH information I keep seeing?

Also, if I were to use pycharm instead of the python compiler via terminal would I even need homebrew because doesn't pycharm manage everything via pip anyways? I noticed something called pip3.... what is that? In windows I just typed in Python -m pip install asdf and it worked fine. I assumed, typing python3 -m pip install would install to the python3 directory unless I'm missing something?

Well then, that led me to find some information about virtual environments and I don't understand what's going on anymore. I mainly develop in java and never had to create a virtual environment or use anything like homebrew. Any information would be great! Sorry for the longish post.

asnyder002
  • 125
  • 8
  • Welcome to StackOverflow! Please do not ask more than one question by post. Also, try to make your question short, it is currently getting drowned in unnecessary details. For more tips, read the [how to ask](https://stackoverflow.com/help/how-to-ask) section! – Olivier Melançon Jun 07 '19 at 04:15

3 Answers3

0

PyCharm (by default anyway) creates a Virtual Environment for each project. Essentially, a clean install of the entire Python language interpreter is copied into your project folder. This is so that you can control exactly which packages need to be used for a project, keep from overcrowding your installed packages, and avoid any namespace collisions.

Look here for directions on how to set such a virtualenv up from the command line.

Here is a SO question about the differences between Homebrew and Pip.

Dennis
  • 2,249
  • 6
  • 12
0

It is more accurate to use the analogy of pip as a subset of Homebrew, since Homebrew manages more than just Python. In fact, Homebrew is an equivalent to RPM (Linux). There is no direct Windows equivalent, but the Windows Store or Steam (if you play games) is sort of in the same ballpark.

pip3 is just the Python3 version of pip.

Finally, virtual environments in Python are kind of cool. What happens when you create a venv, is just the base Python is moved. Since you could use Python2 or Python3 (or several different versions of each) is that you get JUST that version in the venv. So, you would not have to worry about python vs python3 or pip vs pip3 in the venv.

Plus, initially, the venv doesn't contain any other packages. You can just install the packages you need in that venv. Since some packages can collide with others, this makes it really useful.

Hope this helps. I just went down those rabbit holes myself. LOL!

0

Then someone recommended I install it using HomeBrew. So I don't really understand Homebrew... it's like what pip is to python, what homebrew is to macOS?

Homebrew is a package manager for MacOS, you can certainly look at it as to what pip is to python. Both manage packages, whether it be setting up PATHS, installation or deletion. Homebrew is far more convenient than having to create package directories and PATHS yourself. I highly recommend using it, they have tons of excellent documentation to help you out.

Also, what is all this PATH information I keep seeing?

Lindes answered that question here in great detail. In short, it's the directory location where executable can be found.

I noticed something called pip3.... what is that?

pip3 is used to install packages for python3 instead of python2. Using just pip to install packages while using a python3 build will lead to incompatibilities.

Also, if I were to use pycharm instead of the python compiler via terminal would I even need homebrew because doesn't pycharm manage everything via pip anyways?

Pycharm is an IDE, it's doubtful that an IDE will be a good replacement for a package manager.

...that led me to find some information about virtual environments and I don't understand what's going on anymore.

This has also been answered in great detail.

GKE
  • 960
  • 8
  • 21