Ubuntu에서 Python3 환경 셋업을 한 뒤에 (https://www.whatwant.com/entry/Python3-환경-만들기-버전-변경하기-in-Ubuntu)

pandas를 사용해보고자 했더니, 에러가 발생...


Traceback (most recent call last):

  File "./test.py", line 4, in <module>

    import pandas as pd

ModuleNotFoundError: No module named 'pandas'




0. 현재 환경


    - 아래 작업을 실행한 환경은 다음과 같다


$ lsb_release -a


No LSB modules are available.

Distributor ID: Ubuntu

Description:    Ubuntu 18.04.3 LTS

Release:        18.04

Codename:       bionic



$ python --version


Python 3.6.9


    - Python 3.7 버전으로 했을 경우에는 아래와 같이 진행하면 충돌(?)이 있다. 3.6 버전으로 진행하길...




1. pandas 설치하기


    - 뭔가 무지막지하게 많이 설치된다.


$ sudo apt-get install python3-pandas


Reading package lists... Done

Building dependency tree

Reading state information... Done

The following additional packages will be installed:

  blt fonts-lyx javascript-common libaec0 libblas3 libblosc1 libgfortran4 libhdf5-100 libjbig0 libjpeg-turbo8 libjpeg8 libjs-jquery libjs-jquery-ui liblapack3 liblcms2-2 libsnappy1v5 libsz2 libtcl8.6 libtiff5 libtk8.6 libwebp6 libwebpdemux2

  libwebpmux3 libxft2 libxrender1 libxss1 python-matplotlib-data python-tables-data python3-bs4 python3-cycler python3-dateutil python3-decorator python3-html5lib python3-lxml python3-matplotlib python3-numexpr python3-numpy python3-olefile

  python3-pandas-lib python3-pil python3-pyparsing python3-scipy python3-tables python3-tables-lib python3-tk python3-tz python3-webencodings tk8.6-blt2.5 ttf-bitstream-vera x11-common

Suggested packages:

  blt-demo apache2 | lighttpd | httpd libjs-jquery-ui-docs liblcms2-utils tcl8.6 tk8.6 python-cycler-doc python3-genshi python3-lxml-dbg python-lxml-doc dvipng ffmpeg gir1.2-gtk-3.0 ghostscript inkscape ipython3 librsvg2-common

  python-matplotlib-doc python3-cairocffi python3-gi-cairo python3-gobject python3-nose python3-pyqt4 python3-sip python3-tornado texlive-extra-utils texlive-latex-extra ttf-staypuft gfortran python-numpy-doc python3-dev python3-numpy-dbg

  python-pandas-doc python-pil-doc python3-pil-dbg python-pyparsing-doc python-scipy-doc python-tables-doc python3-netcdf4 vitables tix python3-tk-dbg

The following NEW packages will be installed:

  blt fonts-lyx javascript-common libaec0 libblas3 libblosc1 libgfortran4 libhdf5-100 libjbig0 libjpeg-turbo8 libjpeg8 libjs-jquery libjs-jquery-ui liblapack3 liblcms2-2 libsnappy1v5 libsz2 libtcl8.6 libtiff5 libtk8.6 libwebp6 libwebpdemux2

  libwebpmux3 libxft2 libxrender1 libxss1 python-matplotlib-data python-tables-data python3-bs4 python3-cycler python3-dateutil python3-decorator python3-html5lib python3-lxml python3-matplotlib python3-numexpr python3-numpy python3-olefile

  python3-pandas python3-pandas-lib python3-pil python3-pyparsing python3-scipy python3-tables python3-tables-lib python3-tk python3-tz python3-webencodings tk8.6-blt2.5 ttf-bitstream-vera x11-common

0 upgraded, 51 newly installed, 0 to remove and 0 not upgraded.

Need to get 35.7 MB of archives.

After this operation, 160 MB of additional disk space will be used.

Do you want to continue? [Y/n]




2. 테스트 코드


    - 잘 동작하는지 살펴보자. 샘플은 Kaggle의 내용을 참조했다.


import pandas as pd

import pprint


pp = pprint.PrettyPrinter(indent=4)


if __name__ == "__main__":


    fruits = pd.DataFrame( [[30, 21]], columns=['Apples', 'Bananas'] )

    pp.pprint( fruits )


    exit(0)


파이팅~!!!

반응형

+ Recent posts