python-copy, progressbar module

3 minute read

평소에 헷갈리는 것들과 리눅스에서 파이썬 개발 환경 설정할때 겪은 경험과 해결방법이다.

copy vs. deepcopy in python

python에서 그냥copy(shallow copy)와 deepcopy()차이. 전자는 레퍼런스를 삽입(복사) 후자는 재귀적으로 사본을 삽입(복사)

  • slicing: ex) b=a[:]. 이때 id(a)id(b) 다르다. 아래 역시,
a==b True
a is b False

얕은복사에 해당한다. 이것은 a=[[1,2],[3,4]]같은 mutable in mutable 객체구조 일때 문제생긴다. id(a[0])id(b[0])같은 주소가리킨다.

  • copy 모듈의 copy 메서드 역시 얕은 복사에 해당한다.
  • deepcopy: 깊은 복사는 내부에 객체들까지 모두 새롭게 copy 되는 것이다.

오프셋이란,

  • 두 번째 주소를 만들기 위해 기준이 되는 주소에 더해진 값을 의미한다. 예를 들어, 만약 아래의 수식에서 C가 100번지의 주소를 가리키고 있다면, 그 수식의 결과는 107번지를 의미할 것이다.
C + 7

여기서 이 수식 내의 7이, 바로 오프셋이다. 오프셋을 이용하여 주소를 나타내는 것을 상대주소 지정방식이라고 부르는데, 그 이유는 결과 주소가 다른 지점의 상대적인 위치가 되기 때문이다. 오프셋을 다른 말로 변위라고도 부른다. 


apt 등 업데이트 할때 :

W: The repository 'http://ppa.launchpad.net/mc3man/trusty-media/ubuntu xenial Release' does not have a Release file.

에러나면, remove ppa해야함. software & update -> other software -> 지울거선택 하단 remove버튼

nodejs 설치하려할때 여러 ppa ?repo? 불러올때 에러가 떠서 확인햇고 이걸 지우니까 nodejs 수월하게 설치됨

## Run `sudo apt-get install -y nodejs` to install Node.js 14.x and npm
## You may also need development tools to build native addons:
     sudo apt-get install gcc g++ make
## To install the Yarn package manager, run:
     curl -sL https://dl.yarnpkg.com/debian/pubkey.gpg | gpg --dearmor | sudo tee /usr/share/keyrings/yarnkey.gpg >/dev/null
     echo "deb [signed-by=/usr/share/keyrings/yarnkey.gpg] https://dl.yarnpkg.com/debian stable main" | sudo tee /etc/apt/sources.list.d/yarn.list
     sudo apt-get update && sudo apt-get install yarn

이상은 nodejs를

curl -sL https://deb.nodesource.com/setup_12.x | sudo -E bash

이방법으로 설치하려 할때 뜨는 지시.

progressbar

이것은 jupyter등에서 실행경과를 지속적으로 띄워주는, 바 형태의 진행률을 보여주는 툴킷이다.

근데 설치가 안된다

nodejs npm 설치해도 fastprogress는 안됨. tqdm은 바로되고, 사실 fastprogress도 콘솔에선 됨. 현재 노트북 or 랩에서 안되는 현상.

conda통해 jupyterlab_widgets, ipywidgets 두개 패키지를 설치하고 랩을 실행시켯지만 여전히 progress bar안나옴 랩 로그에서 ipyparallel 이란것을 찾을수없다나와 찾아서 설치해줌.

설치해도 안됨.

어디서 ipython 6.0<= 을 써야한다고해서 업데이트했지만 정작 원인은 다른 데에 있었다.

원인은..

어이없게도 my-torch-env3.6에 matplotlib 설치 안되잇엇음.

fastprogress에 있는 노트북 환경 결정하는 메서드를 보고 참고함.

newline vs. carriage return

  • \n is the newline character, while \r is the carriage return. They differ in what uses them. Windows uses \r\n to signify the enter key was pressed, while Linux and Unix use \n to signify that the enter key was pressed.

jupyter-kite

  • jupyter설치한 익스텐션삭제후 jupyter labextension list로 config,data,runtime경로확인해서삭제후 남아잇는 익스텐션 흔적수동으로 삭제.(kite 삭제후 jupyter 실행시 계속 fix팝업이 뜰 경우)