설치된 패키지 목록 파일로 저장

$ pip freeze > requirements.txt
$ conda list -e > requirements.txt

 

패키지 목록 파일로 설치

$ pip install -r requirements.txt
$ conda install -file requirements.txt

'Python' 카테고리의 다른 글

How To Update All Python Packages  (0) 2021.10.13
Anaconda3  (0) 2021.08.16
Fibonacci series  (0) 2021.08.16
Array/List  (0) 2021.08.16
Number, String  (0) 2021.08.15

https://www.activestate.com/resources/quick-reads/how-to-update-all-python-packages/

 

How to Update All Python Packages

The pip package manager can be used to update one or more packages system-wide. This guide shows how to update all Python packages for Windows and Linux.

www.activestate.com

1. Check that Python is installed

2. Get a list of all the outdated packages

pip list --outdated

3. Upgrade outdated packages

 

Update All Python Packages On Windows

1. Open a command shell by typing 'powershell' in the Search Box of the Task Bar

2. Enter:

pip freeze | %{$_.split('==')[0]} | %{pip install --upgrade &_}

This will upgrade all packages system-wide to the latest version available in the Python Package Index (PyPI).

 

Update All Python Packages On Linux (Ubuntu)

To upgrade all packages using pip with grep:

pip3 list --outdated --format=freeze | grep -v '^\-e' | cut -d = -f 1 | xargs -n1 pip3 install -U

To upgrade all packages using pip with awk:

pip3 list -o | cut -f1 -d' ' | tr " " "\n" | awk '{if(NR>=3)print)' | cut -d' ' -f1 | xargs -n1 pip3 install -U

 

Updating Python Packages On Windows Or Linux

1. Output a list of installed packages into a requirements file (requirements.txt):

pip freeze > requirements.txt

2. Edit requirements.txt, and replace all '==' with '>='. Use the 'Replace All' command in the editor.

3. Upgrade all outdated packages:

pip install -r requirements.txt --upgrade

 

Updating All Packages In A Virtual Enviroment

The easiest way to update unpinned packages (i.e., packages that do not require a specific version) in a virtual environment is to run following Python script that makes use of pip:

import pkg_resources
from subprocess import call

for dist in pkg_resources.working_set:
    call("python -m pip install --upgrade " + dist.<projectname>, shell=True)

 

Updating All Packages In A Pipenv Environment

The simplest way to update all the unpinned packages in a specific virtual environment created with pipenv is to do the following steps:

1. Activate the Pipenv shell that contains the packages to be upgraded:

pipenv shell

2. Upgrade all packages:

pipenv update

'Python' 카테고리의 다른 글

설치된 패키지 목록 저장 및 복원  (0) 2022.08.25
Anaconda3  (0) 2021.08.16
Fibonacci series  (0) 2021.08.16
Array/List  (0) 2021.08.16
Number, String  (0) 2021.08.15

Anaconda3 > Anaconda Prompt

(base) C:\Users\user>conda update -n base conda
    :
(base) C:\Users\user>conda update --all
    :
(py39-tf-cpu) C:\Users\user>pip install tensorflow
    :
(py39-tf-cpu) C:\Users\user>pip install keras
    :

Anaconda Navigator

  • beautifulsoup4
  • imageio
  • matplotlib
  • opencv
  • scikit-image
  • scikit-learn
  • scipy
  • tqdm

'Python' 카테고리의 다른 글

설치된 패키지 목록 저장 및 복원  (0) 2022.08.25
How To Update All Python Packages  (0) 2021.10.13
Fibonacci series  (0) 2021.08.16
Array/List  (0) 2021.08.16
Number, String  (0) 2021.08.15
>>> # Fibonacci series:
>>> a, b = 0, 1
>>> while a < 10:
...     print(a, end=',')
...     a, b = b, a+b
...
0,1,1,2,3,5,8,13,21,34,55,89,144,233,377,610,987

'Python' 카테고리의 다른 글

설치된 패키지 목록 저장 및 복원  (0) 2022.08.25
How To Update All Python Packages  (0) 2021.10.13
Anaconda3  (0) 2021.08.16
Array/List  (0) 2021.08.16
Number, String  (0) 2021.08.15
values = [ 10, 11, 12, 13, 14, 15, 16, 17, 18, 19 ]

Slicing

print(values[0])   # 10
print(values[-1])  # 19
print(values[-3:]) # [ 17, 18, 19 ] 
print(values[7:])  # [ 17, 18, 19 ]
print(values[:3])  # [ 10, 11, 12 ]
print(values[a:b]) # a <= LIST < b
>>> letters = ['a', 'b', 'c', 'd', 'e', 'f', 'g']

>>> letters[2:5] = ['C', 'D', 'E']   # replace
>>> letters
['a', 'b', 'C', 'D', 'E', 'f', 'g']

>>> letters[2:5] = []    # remove
>>> letters[:] = []      # clear

Operation

list1 = [ 1, 2, 3 ]
list2 = [ 4, 5, 6 ]
list3 = list1 + list2   # [ 1, 2, 3, 4, 5, 6 ]

list1.append(10)   # [ 1, 2, 3, 10 ]
print(len(list1))  # 4

Nested

중첩 가능, 새로운 리스트를 한 리스트의 요소에 포함 가능

>>> a = [ 'a', 'b', 'c' ]
>>> b = [ 1, 2, 3 ]
>>> x = [ a, n ]
>>> x
[['a', 'b', 'c'], [1, 2, 3]]
>>> x[0]
['a', 'b', 'c']
>>> x[0][1]
'b'

'Python' 카테고리의 다른 글

설치된 패키지 목록 저장 및 복원  (0) 2022.08.25
How To Update All Python Packages  (0) 2021.10.13
Anaconda3  (0) 2021.08.16
Fibonacci series  (0) 2021.08.16
Number, String  (0) 2021.08.15

+ Recent posts