Setting Up a Python Development Environment on Ubuntu

힘센캥거루
2022년 12월 5일(수정됨)
9
python

While exploring various options to start a blog, I realized that if I want to operate WordPress, I need to know a bit about server management, and most servers are Linux-based.

So, I decided to get familiar with Linux by using Ubuntu, the most widely distributed version.

This time, I will set up a Python development environment on Ubuntu using VS Code.

During this process, I want to understand the meaning of some commands that are used.

1. Installing VS Code

Most articles suggest downloading the compiled package using the terminal and the sudo wget command.

wget stands for web get, and it downloads files from a given URL source.

Ultimately, to use the wget command, you must go to the site and copy the address.

So, whether you download it directly from the homepage or use wget, it's the same.

So, let's conveniently download it by clicking on the site below.

After downloading, open the explorer to check the file location, then press Ctrl + Alt + t to open the terminal and execute the file.

$ sudo apt install code_1.73.1-1667967334_amd64.deb

sudo means administrator privileges like in Windows.

And apt is a package manager in Ubuntu, similar to the MS Store on Windows or the App Store on Mac OS.

The apt and apt-get commands are almost similar except for the output.

If you choose not to use apt and use the downloaded file instead, you can install it with the following command:

$ sudo dpkg -i code_1.73.1-1667967334_amd64.deb

While the apt command downloads and installs the package from the Ubuntu server, dpkg installs the package from a downloaded file.

You can use either, but it's recommended to use apt for stable installation.

Uploaded ImageUploaded Image

After installation, you will see VS Code in the program list.

2. Installing Python Extensions

Python is pre-installed in Ubuntu.

It’s similar to how a global Python 3.9 is pre-installed on a MacBook.

Search for python in the Extension tab on the left and install Python and the extension pack.

Uploaded Image

After doing this, create a test.py file and execute print to display content in the terminal.

Uploaded Image

3. Installing Python Modules

First, open a terminal and install pip. Enter python3-pip for Python 3.* or python-pip for Python 2.*.

If you've installed Python via VS Code, it's likely a version 3.*.

$ sudo apt install python3-pip
Uploaded Image

Now, you can use the pip3 command to install modules like selenium and pandas.

Note that when using the pip3 command, do not include sudo. Even if selenium and Python are not compatible, using the sudo command will force installation.

When I first installed Linux, I unknowingly downloaded and installed Python 3.11, but Linux selenium had not yet been updated to support it.

Using the sudo command forced selenium installation, but I couldn't actually call or use the modules.

pip3 install selenium
Uploaded Image

4. In Conclusion...

Initially, when trying Linux, nothing seemed easy from installing to configuring packages.

I suppose this is a common problem when first encountering Linux.

As I use gnome themes and terminals together, I believe that by gradually learning how to use Linux, I will eventually be able to manage it well with just the terminal.

댓글을 불러오는 중...