How to build a new python virtual environment on Ubuntu

Purpose

When you start a new python project, organize the steps to prepare the virtual environment as a memorandum.

Execution environment

Host OS: Windows 10 pro Virtualization software: VirtualBox 6.0 Guest OS: Linux Ubuntu 18.04 Integrated development environment: VS Code 1.44.2

Virtual environment construction procedure

Using venv is convenient because the packages introduced by pip can be made independent for each project. However, the version of python itself cannot be managed, so use another tool such as pyenv if necessary. (Explanation is omitted here)

1. 1. Create a virtual environment

$ mkdir {new_project_name}
$ cd {new_project_name}
$ python3 -m venv {venv_name} //venv_The name can be anything, but in principle it is venv because it is easy to use.

If the following error message is displayed, the python3-venv package is not installed, so install it with the apt command.

The virtual environment was not created successfully because ensurepip is not
available.  On Debian/Ubuntu systems, you need to install the python3-venv
package using the following command.
apt-get install python3-venv

$ apt install python3-venv

2. Create a VS Code workspace

Follow the steps below to create a setting file and save it as a new workspace.

    1. Open VS Code with the following command
$ cd {Project_Directory}   // new_Move to the project directory
$ code .  //Open VS Code
  1. Create a .gitignore file
$ echo "/venv" > .gitignore
    1. Save as workspace Select File >> Save Workspace As ... to open the save window. Enter the workspace name and save.

From now on, you can open the workspace with the following command

$ cd { Project_Directory }    // new_Move to the project directory
$ code {new_workspace_name}.code-workspace

3. 3. Create a repository on github

Create a new repository from the github website. Please refer to "4, Create a new repository on github" on the following site.

Add new repository to Github https://qiita.com/sodaihirai/items/caf8d39d314fa53db4db

Four. Link the local environment with the github repository (how to use the terminal)

Execute the following command from the terminal.

// 
cd { Project_Directory }    // new_Move to the project directory
git init
git add .
git commit -m "first commit"
git remote add origin https://github.com/{ User_Name }/{ Repository_Name }.git
git push -u origin master

You will be prompted to enter your github username and password, enter them and press enter. that's all.

Reference material

venv: Python virtual environment management https://qiita.com/fiftystorm36/items/b2fd47cf32c7694adc2e

Recommended Posts

How to build a new python virtual environment on Ubuntu
How to build a Python environment using Virtualenv on Ubuntu 18.04 LTS
How to build a Django (python) environment on docker
How to build a Python environment on amazon linux 2
How to build a beautiful Python environment on a new Mac and install Jupter Notebook
[Latest] How to build Java environment on Ubuntu
[Venv] Create a python virtual environment on Ubuntu
How to build Java environment on Ubuntu (Linux)
# 2 Build a Python environment on AWS EC2 instance (ubuntu18.04)
Building a Python environment on Ubuntu
Build Python 3.8 + Pipenv environment on Ubuntu 18.04
Build a python3 environment on CentOS7
A note on how to load a virtual environment in PyCharm
How to develop in a virtual environment of Python [Memo]
How to build a python2.7 series development environment with Vagrant
How to build a sphinx translation environment
Build Python3 and OpenCV environment on Ubuntu 18.04
Build a python environment on MacOS (Catallina)
Python virtual environment and packages on Ubuntu
I want to build a Python environment
Steps to install Python environment on Ubuntu
Creating a python virtual environment on Windows
Build a python virtual environment with pyenv
Build a Python + OpenCV environment on Cloud9
Add a Python virtual environment to VSCode
How to create a Python 3.6.0 environment by putting pyenv on Amazon Linux and Ubuntu
# 3 Build a Python (Django) environment on AWS EC2 instance (ubuntu18.04) part2
build Python on Ubuntu
How to manage Python minor version (build virtual environment) on Windows (without Pyenv or WSL)
How to share a virtual environment [About requirements.txt]
Ubuntu18.04.05 Creating a python virtual environment in LTS
Build python environment with pyenv on EC2 (ubuntu)
Build Python3.5 + matplotlib environment on Ubuntu 12 using Anaconda
Simply build a Python 3 execution environment on Windows
Build a python environment with ansible on centos6
Build a Python environment on Mac (Mountain Lion)
How to run MeCab on Ubuntu 18.04 LTS Python
Build a Python development environment on your Mac
Build a simple Python virtual environment without pyenv
Build a Kubernetes environment for development on Ubuntu
Create a Python virtual development environment on Windows
Build a Python development environment on Raspberry Pi
After buying a new Mac, use pyenv + poetry to build a Python environment.
Steps to create a Python virtual environment with VS Code on Windows
How to build a Python virtual execution environment using Visual Studio Code and pipenv on a Windows machine (also Jupyter notebook)
Build python3 environment with ubuntu 16.04
Build Python environment on Windows
Building a Python virtual environment
Build python environment on windows
Build a Python environment offline
Building a Python virtual environment
Build a GVim-based Python development environment on Windows 10 (3) GVim8.0 & Python3.6
How to set up a Python environment using pyenv
Build a python virtual environment with virtualenv and virtualenvwrapper
Build a machine learning Python environment on Mac OS
I made a Python3 environment on Ubuntu with direnv.
Build a GVim-based Python development environment on Windows 10 (1) Installation
Build a Python development environment on Mac OS X
Build a Python virtual environment using venv (Django + MySQL ①)
Build a Python environment on your Mac using pyenv
Build a python virtual environment with virtualenv and virtualenvwrapper