Ubuntu18.04.05 Creating a python virtual environment in LTS

Created a virtual environment on Ubuntu without using Anaconda.

environment

Ubuntu18.04.05 LTS python:3.6.9


Virtual environment construction

① Update

$sudo apt-get update
$sudo apt-get upgrade
$sudo reboot

② Install venv

$sudo apt install python3-venv

venv: Tools required to build a virtual environment. It seems that Python 3.3 or later is required.


③ Create a virtual environment

#First, create a directory to create a virtual environment.
$mkdir test_env
$cd test_env

mkdir test_env Screenshot from 2020-12-18 13-31-24 (2).png Move to the directory created by $ cd test_env.


$python -m venv tensorflow

Create a directory for the virtual environment with the name "tensorflow".

Screenshot from 2020-12-18 13-31-37 (2).png

The contents are

Screenshot from 2020-12-18 13-45-19 (3).png

This completes the virtual environment.


  1. Enter the virtual environment
$source test_env/tensorflow/bin/activate

Now it acts as a virtual environment. I created a test_env directory in my home for the virtual environment Furthermore, it is long because it is created as tensorflow under it.

If you created it in your home directory, put it in the environment with source tensorflow/bin/activate.

Screenshot from 2020-12-18 15-35-26.png Screenshot from 2020-12-18 15-35-35.png

In a virtual environment

(tensorflow)~@~$pip3 install numpy
(tensorflow)~@~$pip3 install tensorflow-gpu==1.14
(tensorflow)~@~$pip3 install matplotlob

All you have to do is install and so on. However, only pip3 install opencv-python throws an error and does not work. It hurts to forget to copy the error As a result, pip was old and spit out that it didn't have the required modules.

pip3 install -U pip 

I typed this in and upgraded and it was OK.

After that

pip3 install opencv-python==3.4.11.45

I was able to install it by typing.

I specified the version because I was afraid of problems with the opencv4 system.

For the time being, I managed to get there.

④ Make the virtual environment usable with Jupyter etc.

In a virtual environment

(tensorflow)~@~$pip install ipykernel

#After install
(tensorflow)~@~$ipython kernel install --user --name=tensorflow

Screenshot from 2020-12-18 16-04-53 (2).png Screenshot from 2020-12-18 16-05-53 (2).png

This will allow you to select the kernel in the jupyter notebook.

Screenshot from 2020-12-18 16-06-34 (2).png

Well, I'm trying various things.

Recommended Posts

Ubuntu18.04.05 Creating a python virtual environment in LTS
Creating a python virtual environment on Windows
virtual environment in python
Creating a virtual environment in an Anaconda environment
Create a virtual environment with conda in Python
[Venv] Create a python virtual environment on Ubuntu
Work in a virtual environment with Python virtualenv.
Ubuntu18.04.05 Creating a python virtual environment in LTS
Set a fixed IP in the Linux environment
Building a Python virtual environment
Building a Python virtual environment
Python: Creating a virtual environment (venv), starting and stopping
Building a Python environment on Ubuntu
Create a virtual environment with Python!
Building a virtual environment with Python 3
How to build a new python virtual environment on Ubuntu
[Django3] Display a web page in Django3 + WSL + Python virtual environment
How to develop in a virtual environment of Python [Memo]
[Pyenv] Building a python environment with ubuntu 16.04
Python virtual environment and packages on Ubuntu
Let's create a virtual environment for Python
[Python] Create a virtual environment with Anaconda
[Mac] Building a virtual environment for Python
Build a python virtual environment with pyenv
I started Node.js in a virtual environment
Add a Python virtual environment to VSCode
How to build a Python environment using Virtualenv on Ubuntu 18.04 LTS
From installing Ansible to building a Python environment in Vagrant's virtual environment
When creating an environment that uses python django on Ubuntu 12.04 LTS
How to create a Python virtual environment (venv)
Install python package in personal environment on Ubuntu
Start Django in a virtual environment with Pipenv
python virtual environment Pipenv
[Python] Web development preparation (building a virtual environment)
Build a simple Python virtual environment without pyenv
A memo when creating a python environment with miniconda
Think about building a Python 3 environment in a Mac environment
Commands for creating a python3 environment with virtualenv
Flow of creating a virtual environment with Anaconda
Procedure for creating a Python quarantine environment (venv environment)
Use jupyter-lab installed in python virtual environment (venv)
[Detailed version] Creating a comfortable Python environment with Google Compute Engine (Ubuntu 16.04)
Create a Python environment
Development environment in Python
A memo for creating a python environment by a beginner
Beep in Python (Ubuntu)
Virtual environment with Python 3.6
[Docker] Create a jupyterLab (python) environment in 3 minutes!
Create a Python virtual development environment on Windows
Create a Django project and application in a Python virtual environment and start the server
Operate mongoDB from python in ubuntu environment ① Introduction of mongoDB
# 2 Build a Python environment on AWS EC2 instance (ubuntu18.04)
Build a python virtual environment with virtualenv and virtualenvwrapper
Notes on creating a python development environment on macOS Catalina
I made a Python3 environment on Ubuntu with direnv.
Build a Python virtual environment using venv (Django + MySQL ①)
Building and enabling a python virtual environment, etc. (venv)
Build a python virtual environment with virtualenv and virtualenvwrapper
Notes on creating a virtual environment with Anaconda Navigator
Setting up Jupyter Lab in a Python 3.9 venv environment
Take a screenshot in Python
Create a function in Python