What is the difference between `pip` and` conda`?

background

Why install with conda even though pip can be used in Anaconda's virtual environment? I was wondering and wanted to know if there was a proper use.

Difference between pip and conda

It was written in an easy-to-understand manner on StackOverflow and the anaconda blog. https://stackoverflow.com/questions/20994716/what-is-the-difference-between-pip-and-conda https://www.anaconda.com/understanding-conda-and-pip/

1. Whether it is possible to install libraries other than those written in Python

--In the case of pip, only packages made only with Python can be installed. --If you need a library written in C / C ++ or R language such as HDF5 or LLVM, you need to install it separately. --For conda, you can also install packages written in languages other than Python. --Libraries such as NumPy and Matplotlib that needed to be built when installing from PyPI with pip can now be installed from Anaconda Cloud with conda. ――For example, ** PostgreSQL can be installed and run with conda! ** (described later) --On the contrary, the wheel format media supported by pip cannot be installed by conda. This will be installed using pip.

2. Whether you can create a virtual environment

--You can't make it with pip alone. --It needs to be realized with the help of other tools such as virtualenv and pipenv. --You can make it with just conda. --If you install pip in the created virtual environment, you can use pip as well.

3. Whether to check library compatibility

--For pip, try the installation in order without checking compatibility. --Depending on the order of installation, compatibility may not be maintained and installation may occur, destroying the environment. --In the case of conda, it checks compatibility and tells you the result. --As long as the dependent library related meta information of the package to be installed is correct, conda will take care not to damage the environment.

I installed PostgreSQL with conda

As a test, install PostgreSQL with anaconda and try connecting.

Click here for the reference gist. https://gist.github.com/gwangjinkim/f13bf596fefa7db7d31c22efd1627c7a

Create virtual environment

$ conda create --name myenv

# enter the environment
$ conda activate myenv

PostgreSQL installation

$ conda install -y -c conda-forge postgresql

PostgreSQL initialization

Initialize with the mylocal_db folder as the data folder.

$ initdb -D mylocal_db
...
Success. You can now start the database server using:

    pg_ctl -D mylocal_db -l logfile start

Start PostgreSQL

I will start it immediately. Depending on the added option, the operation is as follows.

--The data folder (-D) is the initialized mylocal_db folder. --Log file (-l) is output to logfile --Use port 5433 (-p 5433) as an option (-o).

$  pg_ctl -D mylocal_db -l logfile -o "-p 5433" start
waiting for server to start.... done
server started

Connect to PostgreSQL

By executing the psql command, you can execute SQL.

$ psql -d postgres -p 5433
psql (11.2)
Type "help" for help.

postgres=# 

Stop PostgreSQL

Execute the stop command (pg_ctl stop) in the same way as the start command (pg_ctl start).

$ pg_ctl -D mylocal_db -l logfile -o "-p 5433" stop
waiting for server to shut down.... done
server stopped

After all, how do you use them properly?

I understand that there are some more convenient cases to install with conda:

--When using a library such as Numpy that needs to be built for each environment in C / C ++ at the time of installation --When using other middleware such as PostgreSQL is a prerequisite ――Is it possible to create a development environment where everything can be completed with just one Anaconda without having to bring out Docker (?)

On the contrary, there may be cases where pip is more convenient. Are many here?

--If you want a pure Python implementation --If the middleware you use cannot be installed with conda

Recommended Posts

What is the difference between `pip` and` conda`?
What is the difference between Unix and Linux?
What is the difference between usleep, nanosleep and clock_nanosleep?
What is the difference between a symbolic link and a hard link?
About the difference between "==" and "is" in python
[Introduction to Python] What is the difference between a list and a tuple?
Difference between == and is in python
[Introduction to Infectious Disease Models] What is the difference between the April epidemic and this epidemic? .. .. ‼
The subtle relationship between Gentoo and pip
The answer of "1/2" is different between python2 and 3
About the difference between PostgreSQL su and sudo
Consideration of the difference between ROC curve and PR curve
The rough difference between Unicode and UTF-8 (and their friends)
Can BERT tell the difference between "candy (candy)" and "candy (rain)"?
How to use argparse and the difference between optparse
What is pip and how do you use it?
Difference between "categorical_crossentropy" and "sparse_categorical_crossentropy"
What is the activation function?
What is the Linux kernel?
Difference between regression and classification
[Python] Python and security-① What is Python?
Difference between np.array and np.arange
Difference between MicroPython and CPython
What is the interface for ...
What is the Callback function?
Difference between ps a and ps -a
Difference between return and print-Python
Understand the difference between cumulative assignment to variables and cumulative assignment to objects
Move what you installed with pip to the conda environment
Difference between SQLAlchemy back_populates and backref and when neither is used
The difference between foreground and background processes understood by the principle
Difference between java and python (memo)
Difference between list () and [] in Python
Difference between SQLAlchemy filter () and filter_by ()
Memorandum (difference between csv.reader and csv.dictreader)
[Python] What is @? (About the decorator)
(Note) Difference between gateway and default gateway
[python] What is the sorted key?
Difference between Numpy randint and Random randint
Difference between sort and sorted (memorial)
Difference between python2 series and python3 series dict.keys ()
What is the X Window System?
What is the python underscore (_) for?
[Python] Difference between function and method
Difference between SQLAlchemy flush () and commit ()
Python --Difference between exec and eval
[Python] Difference between randrange () and randint ()
[Python] Difference between sorted and sorted (Colaboratory)
How to give and what the constraints option in scipy.optimize.minimize is
I investigated the behavior of the difference between hard links and symbolic links
[Python] What is pip? Explain the command list and how to use it with actual examples
[Python] Comprehension notation. Write a for statement simply. (A collection is the difference between an iterator and an iterator)
[Python] What is pandas Series and DataFrame?
[Xg boost] Difference between softmax and softprob
About package management with conda and pip
difference between statements (statements) and expressions (expressions) in Python
[Django ORM] Difference between values () and only ()
Difference between PHP and Python finally and exit
What is the ETL processing framework clivoa?
[Unix] What is the zombie process / orphan process?
Difference between @classmethod and @staticmethod in Python