Clogged with python update of GCP console ①

The problem that stood up

I want to use the API on a web server

↓ The VM instance of GCP is left unattended, so let's put Nginx in it

↓ Insert pip → jam

(Surely I got an error saying that the python version is low here) ↓ Trying to update python with pyenv → jammed

Solved problem

--Apt is being used by another process! Error

--There is no pyenv! I was told After installing it, there is a pyenv configuration file! I was told. --The pass didn't pass.

Referenced site

"If you use Python, you can make a web application" https://qiita.com/cabernet_rock/items/852fc7c5d382fdc422a3

"How to update the python version of Cloud Shell on GCP" https://qiita.com/greenteabiscuit/items/cbecdf4f84f0b73ff96e

"The story of installing pyenv on ubuntu 20.04 [Updated on 2020/07/18]" https://qiita.com/neruoneru/items/1107bcdca7fa43de673d

environment

Ubuntu 16.04.7 LTS (GNU/Linux 4.15.0-1080-gcp x86_64)

Actual steps

$ pip
The program 'pip' is currently not installed. To run 'pip' please ask your administrator to install the package 'python-pip'

$ sudo apt-get update
$ sudo apt install python-pip
E: Could not get lock /var/lib/dpkg/lock-frontend - open (11: Resource temporarily unavailable)
E: Unable to acquire the dpkg frontend lock (/var/lib/dpkg/lock-frontend), is another process using it?

An error has occurred. It seems to be a common error. Isn't it used by another process? And that.


$  rm -rf ~/.pyenv

It didn't work. Or rather, it should have been erased here, but did it come out later?

$ ps aux | grep apt | grep -v 'grep'
root      2035  0.0  0.1   4504   708 ?        Ss   11:37   0:00 /bin/sh /usr/lib/apt/apt.systemd.daily install
root      2050  0.0  0.2   4504  1684 ?        S    11:37   0:00 /bin/sh /usr/lib/apt/apt.systemd.daily lock_is_hel
d install
root      2610  0.7  3.1  39640 18884 pts/1    Ss+  11:39   0:00 /usr/bin/dpkg --status-fd 12 --unpack --auto-decon
figure /var/cache/apt/archives/libx11-data_2%3a1.6.3-1ubuntu2.2_all.deb

I found out when I looked it up, but I don't know which one is the kill PID.

$ sudo apt autoremove

I was able to go with this. I'm not sure, but I think he did a good job and erased the unnecessary things.

Install pyenv

$ sudo apt-get install -y git

$ git clone https://github.com/pyenv/pyenv.git ~/.pyenv
fatal: destination path '/home/[User name]/.pyenv' already exists and is not an empty directory.

It seems that the installation is done, so maybe the path doesn't pass? I guess.

At the referenced site, you should be in the path with the following command.

# add to path
echo 'export PATH="$HOME/.pyenv/bin:$PATH"' >> ~/.bashrc
echo 'eval "$(pyenv init -)"' >> ~/.bashrc
echo 'eval "$(pyenv virtualenv-init -)"' >> ~/.bashrc

If you refer to other sites,

# .bashrc update
echo 'export PYENV_ROOT="$HOME/.pyenv"' >> ~/.bashrc
echo 'export PATH="$PYENV_ROOT/bin:$PATH"' >> ~/.bashrc
echo 'eval "$(pyenv init -)"' >> ~/.bashrc
source ~/.bashrc

It has become. Chant the missing part.

$ source ~/.bashrc
$ pyenv -v
pyenv 1.2.21

It's done!

afterwards

Let's update python right away.

$ pyenv install 3.7.4
Downloading Python-3.7.4.tar.xz...
-> https://www.python.org/ftp/python/3.7.4/Python-3.7.4.tar.xz
Installing Python-3.7.4...
BUILD FAILED (Ubuntu 16.04 using python-build 1.2.21)
Inspect or clean up the working tree at /tmp/python-build.20201015120257.27370
Results logged to /tmp/python-build.20201015120257.27370.log
Last 10 log lines:
    sys.exit(ensurepip._main())
  File "/tmp/python-build.20201015120257.27370/Python-3.7.4/Lib/ensurepip/__init__.py", line 204, in _main
    default_pip=args.default_pip,
  File "/tmp/python-build.20201015120257.27370/Python-3.7.4/Lib/ensurepip/__init__.py", line 117, in _bootstrap
    return _run_pip(args + [p[0] for p in _PROJECTS], additional_paths)
  File "/tmp/python-build.20201015120257.27370/Python-3.7.4/Lib/ensurepip/__init__.py", line 27, in _run_pip
    import pip._internal
zipimport.ZipImportError: can't decompress data; zlib not available
Makefile:1132: recipe for target 'install' failed
make: *** [install] Error 1

Somehow a new error came out ... I've taken a step forward for the time being, so I'll stop here.

Recommended Posts

Clogged with python update of GCP console ①
Clogged with python update of GCP console ② (Solution)
Automatic update of Python module
Implementation of Bulk Update with mongo-go-driver
Replace dictionary value with Python> update ()
Getting Started with Python Basics of Python
Life game with Python! (Conway's Game of Life)
10 functions of "language with battery" python
Implementation of Dijkstra's algorithm with python
Coexistence of Python2 and 3 with CircleCI (1.0)
Basic study of OpenCV with Python
[Blender] List of shortcut keys of Python Console that comes standard with Blender
Python update (2.6-> 2.7)
How to update the python version of Cloud Shell on GCP
Make the Python console covered with UNKO
Basics of binarized image processing with Python
[Examples of improving Python] Learning Python with Codecademy
Execute Python script with cron of TS-220
Automatic update method with python Pyinstaller exe
Check the existence of the file with python
Algorithm learned with Python 8th: Evaluation of algorithm
Output Python log to console with GAE
Easy introduction of speech recognition with Python
[GCP] Operate Google Cloud Storage with Python
UnicodeEncodeError struggle with standard output of python3
1. Statistics learned with Python 1-3. Calculation of various statistics (statistics)
Drawing with Matrix-Reinventor of Python Image Processing-
Recommendation of Altair! Data visualization with Python
Comparison of matrix transpose speeds with Python
[AtCoder] Solve A problem of ABC101 ~ 169 with Python
I tried hundreds of millions of SQLite with python
FizzBuzz with Python3
Scraping with Python
Prepare the execution environment of Python3 with Docker
Statistics with python
Automatic operation of Chrome with Python + Selenium + pandas
Performance comparison of face detector with Python + OpenCV
[Python] limit axis of 3D graph with Matplotlib
Scraping with Python
Algorithm learned with Python 13th: Tower of Hanoi
Python with Go
Color page judgment of scanned image with python
[Note] Export the html of the site with python.
Calculate the total number of combinations with python
Twilio with Python
Integrate with Python
Use multiple versions of python environment with pyenv
Check the date of the flag duty with Python
Play with 2016-Python
Solve A ~ D of yuki coder 247 with python
AES256 with python
Tested with Python
Basics of Python ①
1. Statistics learned with Python 1-2. Calculation of various statistics (Numpy)
Basics of python ①
[Python] Get rid of dating with regular expressions
python starts with ()
How to specify attributes with Mock of python
Poetry-virtualenv environment construction with python of centos-sclo-rh ~ Notes
Copy of python
with syntax (Python)