Notice
Recent Posts
Recent Comments
«   2024/05   »
1 2 3 4
5 6 7 8 9 10 11
12 13 14 15 16 17 18
19 20 21 22 23 24 25
26 27 28 29 30 31
Tags
more
Archives
Today
Total
관리 메뉴

topcue

SageMath on MAC OS X 본문

기타

SageMath on MAC OS X

topcue 2021. 2. 7. 19:43

2020/21/31 수정

OS : macOS Catalina (10.15.7)


Sage math cell

설치가 힘든 경우 웹에서 sage math cell을 사용할 수도 있다.

https://sagecell.sagemath.org/


Sage math on OS X

다음은 PC에서 sage를 사용하는 방법이다.

소스코드를 다운받아 컴파일하거나 빌드된 바이너리를 다운받아 사용하는 방법이 있다.

나는 소스코드 컴파일도 해봤는데 너무 오래 걸린다.

그냥 바이너리 다운받아서 쓰자.

https://www.sagemath.org/download.html

ASIAKAIST, Republic of KoreaApple Mac OS Xintel로 이동

OS X 10.14에 맞게 sage-8.9-OSX_10.14.6-x86_64.tar.bz2를 다운 받았다.

sage math 9.0부터 python3를 지원한다고 한다.

sage-9.0-OSX_10.11.6-x86_64.dmg를 다운 받았다.

sage-9.2-OSX_10.15.7-x86_64.dmg를 다운 받았다.

  • error : Error running the script 'relocate-once.py' .

    MAX OS X 10.14.6에 9.0 버전 이상의 sage를 설치할 때 계속 오류가 발생했다.

    "relocate-once.py"를 실행하던 중 존재하지 않는 디렉토리의 Makefile을 참조하려다 오류가 발생했다.

    어쩌다보니 오류를 해결했는데 이유는 정확히 잘 모르겠다.

    1. PATH="/Library/Frameworks/Python.framework/Versions/3.7/bin:${PATH}"를 ~/.bash_profile에 추가
    1. sage-9.1-OSX_10.11.6-x86_64.tar.bz2를 다운받고 build 없이 sage 바이너리를 실행하니 잘 돌아감
    1. 다시 sage-9.0-OSX_10.11.6-x86_64.dmg를 다운받고 sage 바이너리를 실행하니 잘 돌아감

    아마도 PATH 때문에 그랬던 것 같다.

다운받은 .dmg 파일을 열면 SageMath 디렉토리가 있고, 그안에 sage 바이너리가 있다.

SageMath를 ~/ 로 카피한 뒤 sage에 symbolic link를 걸어보자.

echo $PATH

PATH에 있는 경로 중 /usr/local/bin에 sage 링크를 만들었다.

cd /usr/local/bin
sudo ln -s ~/SageMath/sage sage

sage로 sage script를, sage -sh로 sage shell을 사용할 수 있다.


import python modules on sage

.sage 파일이나 sage script에서 python library를 사용하는 경우가 종종 있다.

sage pip로 다운로드 할 때 오류가 자주 발생해서 해결 방법을 정리하려 한다.

pycrypto.sage에서 import한다고 가정하자.

  1. sage -sh에서 pip install --user 명령어로 설치
  1. sage 명령어를 이용해 package 설치 : sage --pip install --user

2번 방법으로 설치하는 중 아래와 같은 오류가 발생했다.

  • error : sage --pip install --user pycrypto==2.6.1
~/SageMath$ sage --pip install --user pycrypto==2.6.1
pip is configured with locations that require TLS/SSL, however the ssl module in Python is not available.
Collecting pycrypto==2.0.1
  Retrying (Retry(total=4, connect=None, read=None, redirect=None, status=None)) after connection broken by 'SSLError("Can't connect to HTTPS URL because the SSL module is not available.",)': /simple/pycrypto/
  Retrying (Retry(total=3, connect=None, read=None, redirect=None, status=None)) after connection broken by 'SSLError("Can't connect to HTTPS URL because the SSL module is not available.",)': /simple/pycrypto/
  Retrying (Retry(total=2, connect=None, read=None, redirect=None, status=None)) after connection broken by 'SSLError("Can't connect to HTTPS URL because the SSL module is not available.",)': /simple/pycrypto/
  Retrying (Retry(total=1, connect=None, read=None, redirect=None, status=None)) after connection broken by 'SSLError("Can't connect to HTTPS URL because the SSL module is not available.",)': /simple/pycrypto/
  Retrying (Retry(total=0, connect=None, read=None, redirect=None, status=None)) after connection broken by 'SSLError("Can't connect to HTTPS URL because the SSL module is not available.",)': /simple/pycrypto/
  Could not fetch URL https://pypi.org/simple/pycrypto/: There was a problem confirming the ssl certificate: HTTPSConnectionPool(host='pypi.org', port=443): Max retries exceeded with url: /simple/pycrypto/ (Caused by SSLError("Can't connect to HTTPS URL because the SSL module is not available.",)) - skipping
  Could not find a version that satisfies the requirement pycrypto==2.0.1 (from versions: )
No matching distribution found for pycrypto==2.0.1
pip is configured with locations that require TLS/SSL, however the ssl module in Python is not available.
Could not fetch URL https://pypi.org/simple/pip/: There was a problem confirming the ssl certificate: HTTPSConnectionPool(host='pypi.org', port=443): Max retries exceeded with url: /simple/pip/ (Caused by SSLError("Can't connect to HTTPS URL because the SSL module is not available.",)) - skipping

패키지명을 pycrypto, pycrypto-2.0.1, pycrypto==2.6 등등으로 바꾸어 보아도 패키지를 찾을 수 없다고 한다.

원인은 SSLError로 인해 패키지 사이트에 접근을 하지 못했던 것이다.

Solution

아래 사이트에서 패키지 파일을 로컬 저장소에 다운받은 후 패키지 경로를 인자로 넘겨주는 방법을 제시하고 있다.

예) sage --pip install ~/Downloads/[packagename.zip]

https://ask.sagemath.org/question/51130/ssl-error-using-sage-pip-install-to-download-a-package/

pycrypto를 다운 받은 후 아래처럼 로컬 경로를 인자로 주어 설치했다.

sage --pip install --user ~/Downloads/pycrypto-2.6.1.tar.gz

import


참고

[1] sage math cell

https://sagecell.sagemath.org/

[2] sage math download

https://www.sagemath.org/download.html

[3] sage 설치 방법

https://smallorbig.tistory.com/9

[4] sage pip install error solution

https://ask.sagemath.org/question/51130/ssl-error-using-sage-pip-install-to-download-a-package/

Comments