์ต๊ทผ์ ๋ค์ ์ค๋ฅ๊ฐ ํ์๋๊ธฐ ์์ํ์ต๋๋ค.
matplotlib.use() must be called *before* pylab, matplotlib.pyplot,
or matplotlib.backends is imported for the first time.
warnings.warn(_use_error_msg)
/var/build/user_builds/astropy/checkouts/latest/docs/analytic_functions/index.rst:83: WARNING: Exception occurred in plotting index-1
from /var/build/user_builds/astropy/checkouts/latest/docs/analytic_functions/index.rst:
Traceback (most recent call last):
File "/usr/lib/pymodules/python2.7/matplotlib/sphinxext/plot_directive.py", line 515, in run_code
exec code in ns
File "<string>", line 14, in <module>
File "/usr/lib/pymodules/python2.7/matplotlib/pyplot.py", line 1046, in subplots
fig = figure(**fig_kw)
File "/usr/lib/pymodules/python2.7/matplotlib/pyplot.py", line 423, in figure
**kwargs)
File "/usr/lib/pymodules/python2.7/matplotlib/backends/backend_tkagg.py", line 79, in new_figure_manager
return new_figure_manager_given_figure(num, figure)
File "/usr/lib/pymodules/python2.7/matplotlib/backends/backend_tkagg.py", line 87, in new_figure_manager_given_figure
window = Tk.Tk()
File "/usr/lib/python2.7/lib-tk/Tkinter.py", line 1767, in __init__
self.tk = _tkinter.create(screenName, baseName, className, interactive, wantobjects, useTk, sync, use)
TclError: no display name and no $DISPLAY environment variable
matplotlib plot_directive๋ฅผ ์ฌ์ฉํ ๋. RTD ๊ตฌ์ฑ์ด ๋ณ๊ฒฝ๋ ๊ฒ ๊ฐ๊ณ ๋ฐฑ์๋๊ฐ ๊ธฐ๋ณธ์ ์ผ๋ก ๋ํ์์ผ๋ก ์ค์ ๋์ด ์์ต๋๋ค.
(๋๊ตฐ๊ฐ๊ฐ ์ด๊ฒ์ ์ฒ์ ๋ณด๊ณ ํ Astropy ๋ฌธ์ ๋ ๋ค์๊ณผ ๊ฐ์ต๋๋ค: https://github.com/astropy/astropy/issues/3600)
@ericholscher- ์ด ๋ฌธ์ ์ ์์ธ์ด ๋ฌด์์ธ์ง ์์ญ๋๊น? ์ด ๋ฌธ์ ๋ก ์ธํด ํ์ฌ ๋ชจ๋ ํ๋กฏ์ด ์ค๋จ๋์์ผ๋ฉฐ, ์ด๋ ์ฐ๋ฆฌ๊ฐ ํต์ ํ ์ ์๊ณ RTD์ ๊ด๋ จ๋์ด ์์ต๋๋ค. ๋ค๋ฅธ ํ๋ก์ ํธ์๋ ์ด ๋ฌธ์ ๊ฐ ์๋์?
์ฐ๋ฆฌ๋ ๋ด๊ฐ ์๋ ์ด๋ค ๊ฒ๋ ๋ฐ๊พธ์ง ์์์ต๋๋ค. ์ด ํด๊ฒฐ ๋ฐฉ๋ฒ์ ์๋ํ์ต๋๊น?
http://stackoverflow.com/a/3054314
2015๋ 3์ 24์ผ ํ์์ผ ์ค์ 1์ 48๋ถ, Thomas Robitaille < [email protected]
์ผ๋ค:
@ericholscher https://github.com/ericholscher - ์ด๋ค ์์ด๋์ด๊ฐ ๋ ์ ์๋์ง
์ด๊ฒ์ ์ผ์ผํค๋? ํ์ฌ ์ด ๋ฌธ์ ๋ก ์ธํด ๋ชจ๋ ํ๋กฏ์ด ๊นจ์ก์ต๋๋ค.
์ฐ๋ฆฌ๊ฐ ํต์ ํ ์ ์๊ณ RTD์ ๊ด๋ จ์ด ์๋ ๊ฒ ๊ฐ์ต๋๋ค. ๋ค๋ฅธ ํ๋ก์ ํธ์๋ ์๋์ง
์ด ๋ฌธ์ ?โ
์ด ์ด๋ฉ์ผ์ ์ง์ ๋ต์ฅํ๊ฑฐ๋ GitHub์์ ํ์ธํ์ธ์.
https://github.com/rtfd/readthedocs.org/issues/1195#issuecomment -85406365
.
์๋ฆญ ํ์
ํฌํ๋๋์ ๊ฑฐ์ฃผํ๋ ์ธํฐ๋ท ์ ์์ ๋๋
http://ericholscher.com
@ericholscher - ์, ์ฐ๋ฆฌ๋ ์ด๋ฏธ ์ด๊ฒ์ ํธ์ถํ์ง๋ง ๋ค์์ ๋ด ๋๋ค.
/usr/lib/pymodules/python2.7/matplotlib/__init__.py:1173: UserWarning: This call to matplotlib.use() has no effect
because the backend has already been chosen;
matplotlib.use() must be called *before* pylab, matplotlib.pyplot,
or matplotlib.backends is imported for the first time.
๋ฐฑ์๋๊ฐ ์ด๋ฏธ ๋ฏธ๋ฆฌ ์ค์ ๋์ด ์์์ ๋ํ๋ ๋๋ค.
์ด๋ค ์ ์? ๋๋ matplotlib์ ๋ํด ๋ง์ด ์์ง ๋ชปํ๋ฉฐ ์ฐ๋ฆฌ๋ ํด๋ณด์ง ์์์ต๋๋ค.
๋ด๊ฐ ์๋ ๋ชจ๋ ๊ฒ์ด ์ํฅ์ ๋ฏธ์นฉ๋๋ค. ์
๊ทธ๋ ์ด๋ ํ ์ ์์ด ๋ง์กฑ์ค๋ฝ์ต๋๋ค.
1.3.1์ ์ฌ์ฉํ๊ณ ์์ง๋ง ๋ฌธ์ ๋ฅผ ๋๋ฒ๊น
ํ๋ ๋ฐฉ๋ฒ์ ์ ๋ชจ๋ฅด๊ฒ ์ต๋๋ค.
์ํํธ์จ์ด๋ฅผ ์ ํ ๋ชจ๋ฆ
๋๋ค.
2015๋ 3์ 24์ผ ํ์์ผ ์ค์ 9:01, Thomas Robitaille < ์๋ฆผ @github.com
์ผ๋ค:
@ericholscher https://github.com/ericholscher - ์, ์ด๋ฏธ ์ ํ๋ฅผ ๊ฑธ๊ณ ์์ต๋๋ค.
๊ทธ๋ฌ๋ ์ฐ๋ฆฌ๋ ๋ค์์ ๋ด ๋๋ค./usr/lib/pymodules/python2.7/matplotlib/ init .py:1173: UserWarning: matplotlib.use()์ ๋ํ ์ด ํธ์ถ์ ํจ๊ณผ๊ฐ ์์ต๋๋ค.
๋ฐฑ์๋๊ฐ ์ด๋ฏธ ์ ํ๋์๊ธฐ ๋๋ฌธ์ ๋๋ค.
matplotlib.use()๋ _before_ pylab, matplotlib.pyplot,
๋๋ matplotlib.backends๋ฅผ ์ฒ์์ผ๋ก ๊ฐ์ ธ์ต๋๋ค.๋ฐฑ์๋๊ฐ ์ด๋ฏธ ๋ฏธ๋ฆฌ ์ค์ ๋์ด ์์์ ๋ํ๋ ๋๋ค.
โ
์ด ์ด๋ฉ์ผ์ ์ง์ ๋ต์ฅํ๊ฑฐ๋ GitHub์์ ํ์ธํ์ธ์.
https://github.com/rtfd/readthedocs.org/issues/1195#issuecomment -85576963
.
์๋ฆญ ํ์
ํฌํ๋๋์ ๊ฑฐ์ฃผํ๋ ์ธํฐ๋ท ์ ์์ ๋๋
http://ericholscher.com
@mdboom ์ด ๋ช ๊ฐ์ง ์์ด๋์ด๋ฅผ ๊ฐ์ง๊ณ ์์์ง๋ ๋ชจ๋ฆ
๋๋ค. RTD์ ๊ธฐ๋ณธ๊ฐ์ด Agg์ธ ๊ฒ ๊ฐ๊ธฐ ๋๋ฌธ์ ).
์, ์ฃ์กํฉ๋๋ค. ๊ฐ์ง๊ณ ์๋ ๊ฒ ๊ฐ์์. ์ด ๋ฏธ๋๋ฉ๋ฆฌ์คํธ ํ๋ก์ ํธ๋ฅผ ํ์ธํ์ญ์์ค.
https://github.com/astrofrog/test-rtd
RTD ๋ก๊ทธ(https://readthedocs.org/builds/test-rtd-astrofrog/2482239/)๋ ๋ค์์ ๋ณด์ฌ์ค๋๋ค.
Making output directory...
Running Sphinx v1.2.2
TkAgg
๋ฐ๋ผ์ ๊ธฐ๋ณธ ๋ฐฑ์๋๋ TkAgg๋ก ์ค์ ๋ฉ๋๋ค.
@mdboom , ๊ธฐ๋ณธ ๋ฐฑ์๋๊ฐ ์์คํ ์ ์ฒด์์ TkAgg๊ฐ ์๋๋ผ Agg์ธ์ง ํ์ธํ๋ ๋ฐฉ๋ฒ์ ๋ํ ์ ์ ์ฌํญ์ด ์์ต๋๊น? TkAgg ๋ฐฑ์๋๊ฐ RTD์ ํ์ํด์ผ ํ ์ด์ ๊ฐ ์์ต๋๋ค.
/etc/matplotlibrc์ ์ค์ ํ๋ ๊ตฌ์ฑ์ด ์๋ ๊ฒ ๊ฐ์ต๋๋ค.
2015๋ 3์ 24์ผ ํ์์ผ ์ค์ 9์ 14๋ถ, Thomas Robitaille < [email protected]
์ผ๋ค:
์, ์ฃ์กํฉ๋๋ค. ๊ฐ์ง๊ณ ์๋ ๊ฒ ๊ฐ์์. ์ด ๋ฏธ๋๋ฉ๋ฆฌ์คํธ ํ๋ก์ ํธ๋ฅผ ํ์ธํ์ญ์์ค.
https://github.com/astrofrog/test-rtd
RTD ๋ก๊ทธ(https://readthedocs.org/builds/test-rtd-astrofrog/2482239/)
์ผ:์ถ๋ ฅ ๋๋ ํ ๋ฆฌ๋ฅผ ๋ง๋๋ ์ค...
์คํํฌ์ค v1.2.2 ์คํ
TkAgg๋ฐ๋ผ์ ๊ธฐ๋ณธ ๋ฐฑ์๋๋ TkAgg๋ก ์ค์ ๋ฉ๋๋ค.
@mdboom https://github.com/mdboom , ๋ฐฉ๋ฒ์ ๋ํ ์ ์ ์ฌํญ์ด ์์ต๋๊น?
๊ธฐ๋ณธ ๋ฐฑ์๋๊ฐ ์์คํ ์ ์ฒด์์ TkAgg๊ฐ ์๋๋ผ Agg์ธ์ง ํ์ธํ๋ ค๋ฉด?โ
์ด ์ด๋ฉ์ผ์ ์ง์ ๋ต์ฅํ๊ฑฐ๋ GitHub์์ ํ์ธํ์ธ์.
https://github.com/rtfd/readthedocs.org/issues/1195#issuecomment -85586195
.
์๋ฆญ ํ์
ํฌํ๋๋์ ๊ฑฐ์ฃผํ๋ ์ธํฐ๋ท ์ ์์ ๋๋
http://ericholscher.com
@ericholscher - ์ Agg
๋ฐ๊ฟ ์ ์๋์? RTD์ ๊ฐ์ ๋์คํ๋ ์ด๊ฐ ์๋ ์๋ฒ์ ๋ค๋ฅธ ๊ฒ์ด ์์ด์ผ ํ ์ด์ ๊ฐ ์์ต๋๋ค. ๊ทธ๋ฌ๋ฉด ์๋ฌด๋ matplotlib.use
ํด๊ฒฐ ๋ฐฉ๋ฒ์ ์ฌ์ฉํ ํ์๊ฐ ์์ต๋๋ค.
@ericholscher- ์ด์ ์๋ํ๋ ๊ฒ ๊ฐ์ต๋๋ค. ๋ณ๊ฒฝ ํ์ต๋๊น? ๊ทธ๋ ๋ค๋ฉด ์ด ๋ฌธ์ ๋ฅผ ์ข ๋ฃํ ์ ์์ต๋๋ค. :)
์, ๋ณ๊ฒฝ๋์ด์ผ ํฉ๋๋ค. ์์ ํด์ผ ํ๊ธฐ ๋๋ฌธ์ ๊ณ์ ์ด์ด๋ ๊ฒ์
๋๋ค.
์ฐ๋ฆฌ์ ๋ฐฐํฌ ์คํฌ๋ฆฝํธ๋ ๋ง์ฐฌ๊ฐ์ง์ด๋ฏ๋ก ์ ๋ฒ์ ์ ์
๋ฐ์ดํธํ ๋ ๋ค์ ์ค๋จ๋์ง ์์ต๋๋ค.
๋น๋ ์๋ฒ.
2015๋
3์ 24์ผ ํ์์ผ ์ค์ 10์ 53๋ถ, Thomas Robitaille <
[email protected]>์ ๋ค์๊ณผ ๊ฐ์ด ์ผ์ต๋๋ค.
@ericholscher https://github.com/ericholscher - ์๋ํ๋ ๊ฒ ๊ฐ์ต๋๋ค
์ด์ ๋ณ๊ฒฝ ํ์ต๋๊น? ๊ทธ๋ ๋ค๋ฉด ์ด ๋ฌธ์ ๋ฅผ ์ข ๋ฃํ ์ ์์ต๋๋ค. :)โ
์ด ์ด๋ฉ์ผ์ ์ง์ ๋ต์ฅํ๊ฑฐ๋ GitHub์์ ํ์ธํ์ธ์.
https://github.com/rtfd/readthedocs.org/issues/1195#issuecomment -85620289
.
์๋ฆญ ํ์
ํฌํ๋๋์ ๊ฑฐ์ฃผํ๋ ์ธํฐ๋ท ์ ์์ ๋๋
http://ericholscher.com
์ด๊ฒ์ด ๊ณ ์ณ์ ธ์ผ ํ๋ค๊ณ ๋ฏฟ์ผ์ญ์์ค.
์๋
ํ์ธ์, ๋๋ ๊ฐ์ ๋ฌธ์ ๋ฅผ ๋ง๋ฉ๋๋ค.
"๋ฐฑ์๋๊ฐ ์ด๋ฏธ ์ ํ๋์๊ธฐ ๋๋ฌธ์ matplotlib.use()๋ pylab, matplotlib.pyplot ๋๋ matplotlib.backends๋ฅผ ์ฒ์์ผ๋ก ๊ฐ์ ธ์ค๊ธฐ _์ ์_ ํธ์ถํด์ผ ํฉ๋๋ค."
์ด ๋ฌธ์ ๋ฅผ ํด๊ฒฐํ๊ธฐ ์ํด /etc/matplotlibrc๋ฅผ ๊ตฌ์ฑํ๋ ๋ฐฉ๋ฒ์ด ๊ถ๊ธํฉ๋๋ค.
๊ฐ์ฌ ํด์ !!!
์๋ ํ์ธ์ ๋๊ตฌ๋ ์ง ์ด ๋ฌธ์ ๋ฅผ ํด๊ฒฐํ๋ ๋ฐฉ๋ฒ์ ๋ํด ์ธ๊ธํ ์ ์์ต๋๋ค. ์ด ๋ฌธ์ ๋ฅผ ํด๊ฒฐํ๊ธฐ ์ํด /etc/matplotlibrc๋ฅผ ๊ตฌ์ฑํ๋ ๋ฐฉ๋ฒ.
Py ์ฝ๋ ์์ ๋ถ๋ถ์ ๋ค์ ์ค์ ๋ฃ์ผ๋ฉด ๋ชฉ์ ์ด ํด๊ฒฐ๋ฉ๋๋ค.
๊ฐ์ ธ์ค๊ธฐ matplotlib
matplotlib.use('Agg')
์๋
ํ์ธ์,
์ด๊ฒ์ ๋๋ฅผ ์ํด ์ผํ์ง ์์๋ค
๊ฐ์ ธ์ค๊ธฐ matplotlib
matplotlib.use('Agg')
๊ทธ๋์ ๋์ ๋ค์์ ์ฌ์ฉํ์ต๋๋ค.
matplotlib.pyplot์ plt๋ก ๊ฐ์ ธ์ค๊ธฐ
plt.switch_backend('agg')
๊ทธ๊ฒ ํจ๊ณผ๊ฐ ์์๋ค. ์๋ง๋ ๋ค๋ฅธ ์ฌ๋์๊ฒ ๋์์ด ๋ ๊ฒ์ ๋๋ค.
์๋
ํ์ธ์, ์ ๋ @windows ์์ spyder์์ ํจ๊ณผ์ ์ด์์ต๋๋ค.
๋๊ตฌ> ํ๊ฒฝ ์ค์ > IPython ํฐ๋ฏธ๋> ๊ทธ๋ํ๋ก ์ด๋ํ์ญ์์ค (๋ด ์คํ์ด๋๋ ์คํ์ธ์ด์ด๋ฏ๋ก ๋ฉ๋ด ์ด๋ฆ์ ๊ทผ์ฌ์น์
๋๋ค)
์ฌ๊ธฐ์์ "์ง์ ํ์ฑํ" ํ์ธ๋์ ์ ํ์ ์ทจ์ํฉ๋๋ค.
์คํ์ด๋๋ฅผ ๋ค์ ์์ํ ๋ค์ ๋ค์์ ์ ๋ ฅํ์ญ์์ค.
๊ฐ์ ธ์ค๊ธฐ matplotlib
matplotlib.use('TkAgg')
matplotlib.pyplot์ plt๋ก ๊ฐ์ ธ์ค๊ธฐ
a = [1, 2, 3, 4]
b = [2, 4, 6, 8]
plt.plot(a, b)
๋์์ด ๋๊ธฐ๋ฅผ ๋ฐ๋๋๋ค.
์ด ๋ฌธ์ ๊ฐ Python 3.6 ์ด๋ฏธ์ง์์ ๋ค์ ๋ํ๋ ์ ์์ต๋๊น? ์ป์ ๋๋ถํฐ
No module named '_tkinter'
์ต์ ์ด๋ฏธ์ง์ ํจ๊ป matplotlib๋ฅผ ๊ฐ์ ธ์ค๋ ๋ชจ๋์ ๊ฒฝ์ฐ.
@Tillsten ๊ทํ์ requirements.txt ํ์ผ์ ํด๋น ์๊ตฌ ์ฌํญ์ ์ง์ ํ๋ ค๊ณ ํ์ต๋๊น? ์ฌ์ ํ ๋ฌธ์ ๊ฐ rtd์ ๊ด๋ จ๋์ด ์๋ค๊ณ ์๊ฐ๋๋ฉด rtd ํ๋ก์ ํธ ๋งํฌ๋ก ์ ๋ฌธ์ ๋ฅผ ์ฌ์ญ์์ค.
๊ทธ๋, ๋ด๊ฐ ํ์ด. ๋ฌธ์ ๋ ์ด ๋ฌธ์ ์ ๋์ผํ ๊ฒ ๊ฐ์ต๋๋ค. matplotlib๊ฐ ์ค์น๋์์ง๋ง ๊ธฐ๋ณธ ๋ฐฑ์๋๊ฐ tkagg(tkinter ์ฌ์ฉ)๋ก ์ค์ ๋์ด ์์ผ๋ฉฐ ์ด๋ ํค๋๋ฆฌ์ค rtd-image์์ ์ฌ์ฉํ ์ ์์ต๋๋ค. ์ด ๋ฌธ์ ๋ ์์ ๊ฐ์ด rc ํ์ผ์ ๋ณ๊ฒฝํ๊ฑฐ๋ matplotlib๋ฅผ 3.0์ผ๋ก ์ ๊ทธ๋ ์ด๋ํ๋ฉด ํด๊ฒฐํ ์ ์์ต๋๋ค. ๊ทธ๋ฌ๋ฉด ํด๋น ๋ฌธ์ ๊ฐ ํด๊ฒฐ๋ฉ๋๋ค.
ํ์ฌ ํด๊ฒฐ ๋ฐฉ๋ฒ์ sphinx conf.py
์์ matplotlib ๋ฐฑ์๋๋ฅผ ๊ฐ์ ธ์ค๊ณ ์ค์ ํ๋ ๊ฒ์
๋๋ค.
import matplotlib
matplotlib.use('agg')
ํด๊ฒฐ ๋ฐฉ๋ฒ์ ๊ณต์ ํด ์ฃผ์ ์ ๊ฐ์ฌํฉ๋๋ค! ๋์ค์ ๋์ปค ์ด๋ฏธ์ง๋ฅผ ์ดํด๋ณด๊ฒ ์ต๋๋ค.
๋๋ ์ด๊ฒ๊ณผ ๊ด๋ จ๋ ๋์ปค ์ด๋ฏธ์ง์์ ๋ค๋ฅธ ๊ฒ์ ๋ณด์ง ๋ชปํ๊ธฐ ๋๋ฌธ์ ์ด๊ฒ์ด ์ด๋ป๊ฒ ํด๊ฒฐ๋์๋์ง ์ ๋ชจ๋ฅด๊ฒ ์ต๋๋ค. ํด๊ฒฐ ๋ฐฉ๋ฒ์ด ์์ผ๋ฏ๋ก ๋ค์ ์ด์ด์ผ ํ๋์ง ํ์คํ์ง ์์ต๋๋ค. ์ด๊ฒ์ ์์ฃผ ๋ฌป๋ ์ง๋ฌธ์ ์ถ๊ฐํ์๊ฒ ์ต๋๊น?
๊ฐ์ฅ ์ ์ฉํ ๋๊ธ
์๋ ํ์ธ์,
์ด๊ฒ์ ๋๋ฅผ ์ํด ์ผํ์ง ์์๋ค
๊ฐ์ ธ์ค๊ธฐ matplotlib
matplotlib.use('Agg')
๊ทธ๋์ ๋์ ๋ค์์ ์ฌ์ฉํ์ต๋๋ค.
matplotlib.pyplot์ plt๋ก ๊ฐ์ ธ์ค๊ธฐ
plt.switch_backend('agg')
๊ทธ๊ฒ ํจ๊ณผ๊ฐ ์์๋ค. ์๋ง๋ ๋ค๋ฅธ ์ฌ๋์๊ฒ ๋์์ด ๋ ๊ฒ์ ๋๋ค.