Ruby, Python Module Installation Guide

Introduction

Development of LL languages such as Ruby / Python can be started easily, and many convenient libraries (formally modules, so the following modules) have been developed. For example, the following is an example.

By using such a module, development is possible in a short time. However, unlike the ease of getting started with the LL language, I think that the introduction of modules is not easy to compliment. I often get an error when installing a module and look for a solution based on that message. Even if a solution is found, there are often cases where "I don't know, but somehow this has fixed it", and such information alone cannot be applied.

Module installation is basically a simple task, so it's easy once you get used to it. However, there seems to be no cohesive information to be able to solve the problem on my own, so I will record it.

Target

OS: * nix system Language: Ruby / Python Reader: Anyone who has installed Ruby or Python and started writing programs

goal

The purpose of this post is to document the basic knowledge of module installation in Ruby / Python and how to deal with possible troubles in the future.

Module type

As the reader knows, the module is loaded in the source code as follows. (Example 1) Ruby: require "some_module" Python: import "somemodule"

The module is loaded in this way, but it can be divided into the following two patterns for explanation depending on the file actually loaded.

1. Pure Ruby / Python module

In this case, the file loaded in (Example 1) is in the module search target directory. Ruby: some_module.rb Python: somemodule.py is. If you haven't loaded any additional modules other than the standard library in these files, that file completes the dependency. It's plain Ruby / Python code, so as you can imagine, it's very easy to install.

2. Expansion module

In this case, the file loaded in (Example 1) is also in the module search target directory. Ruby: some_module.so Python: somemodule.so is. This is the module that is easy to trip over during installation.

This file is (essentially) a program compiled in C or C ++. Therefore, in order to use such an extension module, it is necessary to compile the C or C ++ source code during the installation process. Of course, it is not necessary if the compiled file (binary) is provided. However, there are not many cases provided, and most of the time you need to compile.

In other words, solving problems and dependencies that occur during compilation during installation is the solution to Ruby / Python module installation problems.

I'd like to summarize the solution briefly, but in order to solve it on my own, I would like to summarize where the problems at module compilation occur and where the dependencies occur.

How the module is organized

Dependencies (Ruby API / Python API)

Dependencies (C / C ++)

Build options

Module installation

Option 1: Use an OS package management system

Option 2: Use a Ruby / Python package management system

What to do if installation fails

Case Study



I think it will be a slow pace, but I will update it from time to time.

(2014.06.17) The content of "Module type" was added.

Recommended Posts

Ruby, Python Module Installation Guide
Python installation
Python installation
Python module import
Python Tools for Visual Studio Installation Guide
Python collections module
Python installation 2020 (macOS)
Python3.4 installation notes
[Python of Hikari-] Chapter 08-04 Module (Installation of external library)
Python Beginner's Guide (Functions)
Python module (Python learning memo ④)
Python basic course (2 Python installation)
Reinforcement learning 1 Python installation
Create a Python module
Python installation method Windows
python original module import
Ruby, Python and map
Installation of Python 3.3 rc1
Python 2.7 installation (yum) (CentOS 6.8)
Python and Ruby split
Python Dictionary Beginner's Guide
Python Beginner's Guide (Introduction)
Installation of matplotlib (Python 3.3.2)
Python 3.5 installation (yum) (CentOS 6.8)
python (pyenv + pyenv-virtualenv) + CentOS7 installation
Sort Python module imports alphabetically
Python CMS Mezzanine installation procedure
How Python module import works
Python on Ruby and angry Ruby on Python
Java VS PHP VS Python VS Ruby
Python 3.6 installation procedure [for Windows]
About the Python module venv
Automatic update of Python module
Python and ruby slice memo
Python installation and basic grammar
Standard input / summary / python, ruby
OpenCV3 installation for Python3 @macOS
Python installation (Mac edition) (old)
Fastest Python installation on Windows
Zundokokiyoshi with python / ruby / Lua
About Perl, Python, PHP, Ruby
Python 3 series installation for mac
Ruby and Python syntax ~ branch ~
Python Beginner's Guide (Variables / Arrays)
Python debug and test module
Cocos2d-x ~ Installation Guide for Mac ~
Source installation and installation of Python
Python (Python 3.7.7) installation and basic grammar
Module summary that automates and assists WebDriver installation with Python
[Swift / Ruby / Python / Java] Object-oriented programming
Difference between Ruby and Python split
Installation of SciPy and matplotlib (Python)
[Python] logging in your own module
I tried to touch Python (installation)
Multi-stage selection (Go / C # / Ruby / Python)
Scraping with Node, Ruby and Python
Python practice_Virtual environment setup ~ Django installation
Python error: ModuleNotFoundError: No module named'flask'
Dynamic proxy with python, ruby, PHP
Call popcount from Ruby / Python / C #
Python memo Anaconda installation (Mac only)