Backend/ETC

리눅스 서버 python 환경 설정(python 환경변수, pandas 모듈)

jellylucy 2021. 1. 26. 22:54

배경

 

내가 만든 파이썬 실행파일을 리눅스가상서버에 넣고 실행을 했더니 계속 오류가 난다.

import 구문에서 

azureuser@myVM:~$ python slackbot_2021.py
/home/azureuser/.local/lib/python2.7/site-packages/azure/storage/blob/_shared/encryption.py:15: CryptographyDeprecationWarning: Python 2 is no longer supported by the Python core team. Support for it is now deprecated in cryptography, and will be removed in the next release.
  from cryptography.hazmat.backends import default_backend
Traceback (most recent call last):
  File "slackbot_2021.py", line 9, in <module>
    from pandas import json_normalize
ImportError: cannot import name json_normalize

import으로 json_normalize 모듈을 가져오는데 실패했다.

 

 

json_normalize 가 어느 pandas에 들어가있는지 확인 후, pandas 재설치

pandas.pydata.org/pandas-docs/stable/reference/api/pandas.json_normalize.html

 

pandas.json_normalize — pandas 1.2.1 documentation

If True, prefix records with dotted (?) path, e.g. foo.bar.field if path to records is [‘foo’, ‘bar’].

pandas.pydata.org

python 환경변수로 python3 디폴트로 변경하기

 

python 설치, python3 설치.. 

왜 따로 설치명령어가 있는지 알고 싶었다. 

 

나의 가상머신을 python2가 깔린 상태이고 이후에 python3을 깔아도,

python파일은 python2로 실행된다.

 

python3으로 실행되게끔 환경변수를 변경해준다.