

<?xml version="1.0" encoding="UTF-8"?><rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>macOS &#8211; Max的程式語言筆記</title>
	<atom:link href="https://stackoverflow.max-everyday.com/tag/macos/feed/" rel="self" type="application/rss+xml" />
	<link>https://stackoverflow.max-everyday.com</link>
	<description>我要當一個豬頭，快樂過每一天</description>
	<lastBuildDate>Sun, 21 Apr 2024 13:08:30 +0000</lastBuildDate>
	<language>zh-TW</language>
	<sy:updatePeriod>
	hourly	</sy:updatePeriod>
	<sy:updateFrequency>
	1	</sy:updateFrequency>
	<generator>https://wordpress.org/?v=6.9.1</generator>

<image>
	<url>https://stackoverflow.max-everyday.com/wp-content/uploads/2017/02/max-stackoverflow-256.png</url>
	<title>macOS &#8211; Max的程式語言筆記</title>
	<link>https://stackoverflow.max-everyday.com</link>
	<width>32</width>
	<height>32</height>
</image> 
	<item>
		<title>python macos arm tkinter messagebox autorelease pool page error</title>
		<link>https://stackoverflow.max-everyday.com/2024/04/python-macos-arm-tkinter-messagebox-autorelease-pool-page-error/</link>
					<comments>https://stackoverflow.max-everyday.com/2024/04/python-macos-arm-tkinter-messagebox-autorelease-pool-page-error/#respond</comments>
		
		<dc:creator><![CDATA[max-stackoverflow]]></dc:creator>
		<pubDate>Sun, 21 Apr 2024 08:05:07 +0000</pubDate>
				<category><![CDATA[Python筆記]]></category>
		<category><![CDATA[macOS]]></category>
		<category><![CDATA[Python]]></category>
		<guid isPermaLink="false">https://stackoverflow.max-everyday.com/?p=5656</guid>

					<description><![CDATA[在 macOS arm 上，使用 tkinter...]]></description>
										<content:encoded><![CDATA[
<p>在 macOS arm 上，使用 tkinter messagebox 會讓程式掛掉。顯示錯誤訊息：</p>



<pre class="wp-block-preformatted">objc[72371]: autorelease pool page 0x1259de000 corrupted</pre>



<figure class="wp-block-image size-full"><img fetchpriority="high" decoding="async" width="551" height="143" src="https://stackoverflow.max-everyday.com/wp-content/uploads/2024/04/截圖-2024-04-21-下午4.03.24.png?v=1713686623" alt="" class="wp-image-5657"/></figure>



<p>解法：<br><a href="https://stackoverflow.com/questions/75592713/how-to-close-messagebox-of-tkinter-automatic-after-a-few-seconds-in-python">https://stackoverflow.com/questions/75592713/how-to-close-messagebox-of-tkinter-automatic-after-a-few-seconds-in-python</a></p>



<pre class="wp-block-code"><code>import tkinter as tk
import tkinter.messagebox as msgbox

def showMessage(message, timeout=5000):
    root = tk.Tk()
    root.withdraw()
    root.after(timeout, root.destroy)
    msgbox.showinfo('Info', message, master=root)

showMessage('Your Message Here')</code></pre>



<p>實際測試，上面的解法，還是無法彈出msgbox, 但致少知道是msgbox 造成的錯誤，完全不使用messagebox 就解決了。但變成要使用其他方式來彈出錯誤訊息。</p>
]]></content:encoded>
					
					<wfw:commentRss>https://stackoverflow.max-everyday.com/2024/04/python-macos-arm-tkinter-messagebox-autorelease-pool-page-error/feed/</wfw:commentRss>
			<slash:comments>0</slash:comments>
		
		
			</item>
		<item>
		<title>python 如何檢查使用 arm 電腦</title>
		<link>https://stackoverflow.max-everyday.com/2023/06/python-%e5%a6%82%e4%bd%95%e6%aa%a2%e6%9f%a5%e4%bd%bf%e7%94%a8-arm-%e9%9b%bb%e8%85%a6/</link>
					<comments>https://stackoverflow.max-everyday.com/2023/06/python-%e5%a6%82%e4%bd%95%e6%aa%a2%e6%9f%a5%e4%bd%bf%e7%94%a8-arm-%e9%9b%bb%e8%85%a6/#respond</comments>
		
		<dc:creator><![CDATA[max-stackoverflow]]></dc:creator>
		<pubDate>Sat, 03 Jun 2023 03:43:33 +0000</pubDate>
				<category><![CDATA[Python筆記]]></category>
		<category><![CDATA[macOS]]></category>
		<category><![CDATA[Python]]></category>
		<guid isPermaLink="false">https://stackoverflow.max-everyday.com/?p=4869</guid>

					<description><![CDATA[解法，檢查有無 &#8220;-arm&#822...]]></description>
										<content:encoded><![CDATA[
<p>解法，檢查有無 &#8220;-arm&#8221; 即可。</p>



<figure class="wp-block-image size-full"><img decoding="async" width="350" height="95" src="https://stackoverflow.max-everyday.com/wp-content/uploads/2023/06/Screen-Shot-2023-06-03-at-11.39.36-AM-1.png" alt="" class="wp-image-4871"/></figure>



<p>在 macOS x86 取得 platform.platform()</p>



<pre class="wp-block-code"><code>macOS-10.15.7-x86_64-i386-64bit</code></pre>



<p>在 macOS arm:</p>



<pre class="wp-block-code"><code>macOS-12.0.1-arm64-i386-64bit</code></pre>



<p></p>



<p></p>



<p>資料來源：<br><a href="https://stackoverflow.com/questions/70253218/macos-m1-system-is-detected-as-arm-by-python-package-even-though-im-using-roset">https://stackoverflow.com/questions/70253218/macos-m1-system-is-detected-as-arm-by-python-package-even-though-im-using-roset</a></p>



<p><a href="https://stackoverflow.com/users/14122/charles-duffy">Charles Duffy</a>&nbsp;explained the problem in the comments, thank you! <img src="https://s.w.org/images/core/emoji/17.0.2/72x72/1f603.png" alt="😃" class="wp-smiley" style="height: 1em; max-height: 1em;" /></p>



<p>When I checked the platform in Python, it was indeed ARM:</p>



<pre class="wp-block-code"><code>&gt; python -c 'import platform; print(platform.platform())'
macOS-12.0.1-arm64-i386-64bit
</code></pre>



<p>So I had been using a Python installation for ARM.</p>



<p>Now I installed&nbsp;<code>brew</code>&nbsp;and then&nbsp;<code>python3</code>&nbsp;from the Rosetta terminal and used the newly installed Python to initiate a fresh virtual environment, and this fixed it. (<a href="https://medium.com/thinknum/how-to-install-python-under-rosetta-2-f98c0865e012">This article</a>&nbsp;helped me a bit with it.)</p>



<p><strong>Update:</strong></p>



<p>When creating Python environments with&nbsp;<code>conda</code>, it&nbsp;<a href="https://towardsdatascience.com/python-conda-environments-for-both-arm64-and-x86-64-on-m1-apple-silicon-147b943ffa55">is possible</a>&nbsp;to specify whether they should use Apple ARM or Intel-x64:</p>



<ul class="wp-block-list">
<li><code>CONDA_SUBDIR=osx-arm64 conda create -n my_env python</code>&nbsp;makes an ARM environment</li>



<li><code>CONDA_SUBDIR=osx-64 conda create -n my_env python</code>&nbsp;makes an x64 environment</li>
</ul>
]]></content:encoded>
					
					<wfw:commentRss>https://stackoverflow.max-everyday.com/2023/06/python-%e5%a6%82%e4%bd%95%e6%aa%a2%e6%9f%a5%e4%bd%bf%e7%94%a8-arm-%e9%9b%bb%e8%85%a6/feed/</wfw:commentRss>
			<slash:comments>0</slash:comments>
		
		
			</item>
		<item>
		<title>ModuleNotFoundError: No module named &#8216;_tkinter&#8217;</title>
		<link>https://stackoverflow.max-everyday.com/2022/07/modulenotfounderror-no-module-named-_tkinter/</link>
					<comments>https://stackoverflow.max-everyday.com/2022/07/modulenotfounderror-no-module-named-_tkinter/#respond</comments>
		
		<dc:creator><![CDATA[max-stackoverflow]]></dc:creator>
		<pubDate>Tue, 26 Jul 2022 18:33:02 +0000</pubDate>
				<category><![CDATA[Python筆記]]></category>
		<category><![CDATA[linux]]></category>
		<category><![CDATA[macOS]]></category>
		<category><![CDATA[Python]]></category>
		<guid isPermaLink="false">https://stackoverflow.max-everyday.com/?p=4053</guid>

					<description><![CDATA[有網友反應執行了我的程式在他的 Mac m1 電...]]></description>
										<content:encoded><![CDATA[
<p>有網友反應執行了我的程式在他的 Mac m1 電腦上，會顯示錯誤訊息：</p>



<pre class="wp-block-preformatted">&lt;module&gt;
    from tkinter import *
  File "/opt/homebrew/Cellar/python@3.9/3.9.7_1/Frameworks/Python.framework/Versions/3.9/lib/python3.9/tkinter/__init__.py", line 37, in &lt;module&gt;
    import _tkinter # If this fails your Python may not be configured for Tk
ModuleNotFoundError: No module named '_tkinter'</pre>



<hr class="wp-block-separator has-alpha-channel-opacity"/>



<p>打開終端視窗(terminal)並執行以下命令來安裝 tkinter。<br>Open your terminal and run the following command to install tkinter.</p>



<pre class="wp-block-preformatted"># === UBUNTU / DEBIAN ===
sudo apt-get install python3-tk

# Make sure to specify correct Python version.
# For example, my Python 3.10, so I would install as
sudo apt-get install python3.10-tk

# === MacOS ===
brew install python-tk@3.10

# if you run Python v3.9 run adjust command to
brew install python-tk@3.9

# === Fedora ===
sudo dnf install python3-tkinter

# === CentOS ===
sudo yum install python3-tkinter
</pre>
]]></content:encoded>
					
					<wfw:commentRss>https://stackoverflow.max-everyday.com/2022/07/modulenotfounderror-no-module-named-_tkinter/feed/</wfw:commentRss>
			<slash:comments>0</slash:comments>
		
		
			</item>
		<item>
		<title>Compress files from Mac OS X terminal command line</title>
		<link>https://stackoverflow.max-everyday.com/2021/09/compress-files-from-mac-os-x-terminal-command-line/</link>
					<comments>https://stackoverflow.max-everyday.com/2021/09/compress-files-from-mac-os-x-terminal-command-line/#respond</comments>
		
		<dc:creator><![CDATA[max-stackoverflow]]></dc:creator>
		<pubDate>Thu, 02 Sep 2021 22:13:33 +0000</pubDate>
				<category><![CDATA[電腦相關應用]]></category>
		<category><![CDATA[macOS]]></category>
		<guid isPermaLink="false">https://stackoverflow.max-everyday.com/?p=3915</guid>

					<description><![CDATA[以前都是使用 Finder 來操作，發現對具有「...]]></description>
										<content:encoded><![CDATA[
<p>以前都是使用 Finder 來操作，發現對具有「重覆性高」的操作而言實在很浪費人力，應該要使用 command line 來提升效率。</p>



<p>zip 用法：</p>



<pre class="wp-block-preformatted">Copyright (c) 1990-2008 Info-ZIP - Type 'zip "-L"' for software license.
Zip 3.0 (July 5th 2008). Usage:
zip [-options] [-b path] [-t mmddyyyy] [-n suffixes] [zipfile list] [-xi list]
  The default action is to add or replace zipfile entries from list, which
  can include the special name - to compress standard input.
  If zipfile and list are omitted, zip compresses stdin to stdout.
  -f   freshen: only changed files  -u   update: only changed or new files
  -d   delete entries in zipfile    -m   move into zipfile (delete OS files)
  -r   recurse into directories     -j   junk (don't record) directory names
  -0   store only                   -l   convert LF to CR LF (-ll CR LF to LF)
  -1   compress faster              -9   compress better
  -q   quiet operation              -v   verbose operation/print version info
  -c   add one-line comments        -z   add zipfile comment
  -@   read names from stdin        -o   make zipfile as old as latest entry
  -x   exclude the following names  -i   include only the following names
  -F   fix zipfile (-FF try harder) -D   do not add directory entries
  -A   adjust self-extracting exe   -J   junk zipfile prefix (unzipsfx)
  -T   test zipfile integrity       -X   eXclude eXtra file attributes
  -y   store symbolic links as the link instead of the referenced file
  -e   encrypt                      -n   don't compress these suffixes
  -h2  show more help</pre>



<hr class="wp-block-separator"/>



<p>This adds the file&nbsp;<em><code>file</code></em>&nbsp;to the archive&nbsp;<em><code>file.zip</code></em>:</p>



<pre class="wp-block-code"><code>zip file.zip file
</code></pre>



<p>Of course, to add more files, just add them as arguments to the command. Check out&nbsp;<code>man zip</code>&nbsp;for more options.</p>



<p>Often, you&#8217;ll want to skip including those pesky&nbsp;<code>.DS_Store</code>&nbsp;files, for example compressing the whole folder&nbsp;<em><code>folder</code></em>&nbsp;into&nbsp;<em><code>folder.zip</code></em>:</p>



<pre class="wp-block-code"><code>zip -vr <em>folder.zip</em> <em>folder/</em> -x "*.DS_Store"</code></pre>



<p>If you want to make a zip without those invisible Mac resource files such as “_MACOSX” or “._Filename” and .ds store files, use the “-X” option in the command so:</p>



<pre class="wp-block-preformatted">zip -r -X archive_name.zip folder_to_compress</pre>



<hr class="wp-block-separator"/>



<p>To extract</p>



<pre class="wp-block-preformatted">unzip archive_name.zip</pre>



<hr class="wp-block-separator"/>



<p>關於絕對路徑的問題</p>



<p>Create zip file and ignore directory structure</p>



<p>Using&nbsp;<code>-j</code>&nbsp;won&#8217;t work along with the&nbsp;<code>-r</code>&nbsp;option.<br>So the work-around for it can be this:</p>



<pre class="wp-block-code"><code>cd path/to/parent/dir/;
zip -r complete/path/to/name.zip ./* ;
cd -;</code></pre>



<p>Or in-line version</p>



<pre class="wp-block-code"><code>cd path/to/parent/dir/ &amp;&amp; zip -r complete/path/to/name.zip ./* &amp;&amp; cd -
</code></pre>



<p>you can direct the output to&nbsp;<code>/dev/null</code>&nbsp;if you don&#8217;t want the&nbsp;<code>cd -</code>&nbsp;output to appear on screen</p>



<hr class="wp-block-separator"/>



<h2 class="wp-block-heading"><strong>TAR.GZ</strong></h2>



<p>To compress</p>



<pre class="wp-block-preformatted">tar -zcvf archive_name.tar.gz folder_to_compress</pre>



<p>To extract</p>



<pre class="wp-block-preformatted">tar -zxvf archive_name.tar.gz</pre>



<hr class="wp-block-separator"/>



<h2 class="wp-block-heading"><strong>TAR.BZ2</strong></h2>



<p>To compress</p>



<pre class="wp-block-preformatted">tar -jcvf archive_name.tar.bz2 folder_to_compress</pre>



<p>To extract</p>



<pre class="wp-block-preformatted">tar -jxvf archive_name.tar.bz2</pre>



<hr class="wp-block-separator"/>



<h2 class="wp-block-heading"><strong>GZ</strong></h2>



<p>Without the tar</p>



<p>To extract</p>



<pre class="wp-block-preformatted">gunzip archivename.gz</pre>
]]></content:encoded>
					
					<wfw:commentRss>https://stackoverflow.max-everyday.com/2021/09/compress-files-from-mac-os-x-terminal-command-line/feed/</wfw:commentRss>
			<slash:comments>0</slash:comments>
		
		
			</item>
		<item>
		<title>find 指令的結果執行多個指令</title>
		<link>https://stackoverflow.max-everyday.com/2021/07/find-exec-with-multiple-commands/</link>
					<comments>https://stackoverflow.max-everyday.com/2021/07/find-exec-with-multiple-commands/#respond</comments>
		
		<dc:creator><![CDATA[max-stackoverflow]]></dc:creator>
		<pubDate>Sat, 17 Jul 2021 13:24:18 +0000</pubDate>
				<category><![CDATA[電腦相關應用]]></category>
		<category><![CDATA[macOS]]></category>
		<category><![CDATA[Ubuntu]]></category>
		<guid isPermaLink="false">https://stackoverflow.max-everyday.com/?p=3886</guid>

					<description><![CDATA[find 查出的結果，執行多個指令。使用 2個 ...]]></description>
										<content:encoded><![CDATA[
<p>find 查出的結果，執行多個指令。使用  2個 -exec</p>



<p><code>find</code>&nbsp;accepts multiple&nbsp;<code>-exec</code>&nbsp;portions to the command. For example:</p>



<pre class="wp-block-code"><code>find . -name "*.txt" -exec echo {} \; -exec grep banana {} \;</code></pre>



<hr class="wp-block-separator"/>



<p>資料來源</p>



<p>How can I use two bash commands in -exec of find command?</p>



<p>find -exec with multiple commands<br><a href="https://stackoverflow.com/questions/5119946/find-exec-with-multiple-commands">https://stackoverflow.com/questions/5119946/find-exec-with-multiple-commands</a><br></p>
]]></content:encoded>
					
					<wfw:commentRss>https://stackoverflow.max-everyday.com/2021/07/find-exec-with-multiple-commands/feed/</wfw:commentRss>
			<slash:comments>0</slash:comments>
		
		
			</item>
		<item>
		<title>find指令找到的結果的字串處理</title>
		<link>https://stackoverflow.max-everyday.com/2021/07/bash-variable-substitution-on-finds-output-through-exec/</link>
					<comments>https://stackoverflow.max-everyday.com/2021/07/bash-variable-substitution-on-finds-output-through-exec/#respond</comments>
		
		<dc:creator><![CDATA[max-stackoverflow]]></dc:creator>
		<pubDate>Mon, 12 Jul 2021 02:53:57 +0000</pubDate>
				<category><![CDATA[電腦相關應用]]></category>
		<category><![CDATA[linux]]></category>
		<category><![CDATA[macOS]]></category>
		<guid isPermaLink="false">https://stackoverflow.max-everyday.com/?p=3839</guid>

					<description><![CDATA[find 指令在 Linux/Mac 電腦的世界...]]></description>
										<content:encoded><![CDATA[
<p>find 指令在 Linux/Mac 電腦的世界，操作起來很方便，針對找的結果，也可以使用  {} 來取代，做進階的處理，但要怎麼對 {} 的字串，再做更新一步的處理？</p>



<p>例如：找到的 .bmp 的檔案，想輸出成 .png ，或取代掉檔案名裡的特定符號。</p>



<p>Using&nbsp;<a href="https://www.gnu.org/software/bash/manual/bash.html#Brace-Expansion"><code>Brace Expansion</code></a>:</p>



<pre class="wp-block-code"><code>find . -name "*.in" -exec bash -c 'python script.py "${0%.*}"{.in,.out}' {} \;
</code></pre>



<p>Using&nbsp;<a href="https://www.gnu.org/software/bash/manual/bash.html#Shell-Parameter-Expansion"><code>Shell Parameter Expansion</code></a>:</p>



<pre class="wp-block-code"><code>find . -name "*.in" -exec bash -c 'python script.py "${0} ${0/.in/.out}"' {} \;
</code></pre>



<p><strong>Result</strong>:</p>



<pre class="wp-block-code"><code>python script.py somefile.in somefile.out</code></pre>



<hr class="wp-block-separator"/>



<p>To replace the&nbsp;<em>first</em>&nbsp;occurrence of a pattern with a given string, use&nbsp;<code>${<em>parameter</em>/<em>pattern</em>/<em>string</em>}</code>:</p>



<pre class="wp-block-code"><code>#!/bin/bash
firstString="I love Suzi and Marry"
secondString="Sara"
echo "${firstString/Suzi/$secondString}"    
# prints 'I love Sara and Marry'
</code></pre>



<p>To replace&nbsp;<em>all</em>&nbsp;occurrences, use&nbsp;<code>${<em>parameter</em>//<em>pattern</em>/<em>string</em>}</code>:</p>



<pre class="wp-block-code"><code>message='The secret code is 12345'
echo "${message//&#91;0-9]/X}"           
# prints 'The secret code is XXXXX'
</code></pre>



<p>(This is documented in&nbsp;<a href="https://www.gnu.org/software/bash/manual/bash.html#Shell-Parameter-Expansion">the&nbsp;<em>Bash Reference Manual</em>, §3.5.3 &#8220;Shell Parameter Expansion&#8221;</a>.)</p>



<hr class="wp-block-separator"/>



<p>要在 macOS 裡增加 &#8220;U_&#8221; 的 prefix 的方法：</p>



<p>find . -name &#8220;*.png&#8221; -type f -exec bash -c &#8216;mv $0 ${0/\.\//\.\/U_}&#8217; {} \;</p>



<p>直接使用下面的方法，會失敗</p>



<pre class="wp-block-code"><code>find . -type f -exec bash -c 'mv $0 yourPrefix$0' {} \;</code></pre>



<hr class="wp-block-separator"/>



<h2 class="wp-block-heading">詳細用法</h2>



<p>Variable expansion / Substring replacement</p>



<p>These constructs have been adopted from ksh.</p>



<p><strong>${var:pos}</strong><br>Variable var expanded, starting from offset pos.</p>



<p><strong>${var:pos:len}</strong><br>Expansion to a max of len characters of variable var, from offset pos. </p>



<p><strong>${var/Pattern/Replacement}</strong><br>First match of Pattern, within var replaced with Replacement.</p>



<p>If Replacement is omitted, then the first match of Pattern is replaced by nothing, that is, deleted.</p>



<p><strong>${var//Pattern/Replacement}</strong><br>Global replacement. All matches of Pattern, within var replaced with Replacement.</p>



<p>As above, if Replacement is omitted, then all occurrences of Pattern are replaced by nothing, that is, deleted.</p>



<pre class="wp-block-preformatted">stringZ=abcABC123ABCabc

echo ${stringZ/abc/xyz}       # xyzABC123ABCabc
                              # Replaces first match of 'abc' with 'xyz'.

echo ${stringZ//abc/xyz}      # xyzABC123ABCxyz
                              # Replaces all matches of 'abc' with # 'xyz'.

echo  ---------------
echo "$stringZ"               # abcABC123ABCabc
echo  ---------------
                              # The string itself is not altered!

# Can the match and replacement strings be parameterized?
match=abc
repl=000
echo ${stringZ/$match/$repl}  # 000ABC123ABCabc
#              ^      ^         ^^^
echo ${stringZ//$match/$repl} # 000ABC123ABC000
# Yes!          ^      ^        ^^^         ^^^

echo

# What happens if no $replacement string is supplied?
echo ${stringZ/abc}           # ABC123ABCabc
echo ${stringZ//abc}          # ABC123ABC
# A simple deletion takes place.</pre>



<p><strong>${var/#Pattern/Replacement}</strong><br>If prefix of var matches Pattern, then substitute Replacement for Pattern.</p>



<p><strong>${var/%Pattern/Replacement}</strong><br>If suffix of var matches Pattern, then substitute Replacement for Pattern.</p>



<p>stringZ=abcABC123ABCabc</p>



<p>echo ${stringZ/#abc/XYZ} # XYZABC123ABCabc<br># Replaces front-end match of &#8216;abc&#8217; with &#8216;XYZ&#8217;.</p>



<p>echo ${stringZ/%abc/XYZ} # abcABC123ABCXYZ<br># Replaces back-end match of &#8216;abc&#8217; with &#8216;XYZ&#8217;.</p>



<p><strong>${!varprefix*}</strong>,&nbsp;<strong>${!varprefix@}</strong></p>



<p>Matches&nbsp;<em>names</em>&nbsp;of all previously declared variables beginning with&nbsp;<em>varprefix</em>.</p>



<hr class="wp-block-separator"/>



<h2 class="wp-block-heading">資料來源：</h2>



<p>How to substitute string in {} in “find (…) -exec (…) {} \;” bash command?<br><a href="https://stackoverflow.com/questions/50406662/how-to-substitute-string-in-in-find-exec-bash-command#=">https://stackoverflow.com/questions/50406662/how-to-substitute-string-in-in-find-exec-bash-command#<em>=</em></a></p>



<p>Bash variable substitution on find&#8217;s output through exec<br><a href="https://stackoverflow.com/questions/30481590/bash-variable-substitution-on-finds-output-through-exec">https://stackoverflow.com/questions/30481590/bash-variable-substitution-on-finds-output-through-exec</a></p>



<p>Use current filename (“{}”) multiple times in “find -exec”?<br><a href="https://stackoverflow.com/questions/12965400/use-current-filename-multiple-times-in-find-exec">https://stackoverflow.com/questions/12965400/use-current-filename-multiple-times-in-find-exec</a></p>
]]></content:encoded>
					
					<wfw:commentRss>https://stackoverflow.max-everyday.com/2021/07/bash-variable-substitution-on-finds-output-through-exec/feed/</wfw:commentRss>
			<slash:comments>0</slash:comments>
		
		
			</item>
		<item>
		<title>tkinter show error: macOS 11 or later required</title>
		<link>https://stackoverflow.max-everyday.com/2020/12/tkinter-show-error-macos-11-or-later-required/</link>
					<comments>https://stackoverflow.max-everyday.com/2020/12/tkinter-show-error-macos-11-or-later-required/#respond</comments>
		
		<dc:creator><![CDATA[max-stackoverflow]]></dc:creator>
		<pubDate>Wed, 23 Dec 2020 17:03:34 +0000</pubDate>
				<category><![CDATA[Python筆記]]></category>
		<category><![CDATA[macOS]]></category>
		<category><![CDATA[Python]]></category>
		<category><![CDATA[tkinter]]></category>
		<guid isPermaLink="false">http://stackoverflow.max-everyday.com/?p=3646</guid>

					<description><![CDATA[作業系統是 macOS "Big Sur", T...]]></description>
										<content:encoded><![CDATA[
<pre id="block-3cbf8df6-567c-4efc-b697-bd2c9cf4cca8" class="wp-block-preformatted">作業系統是 macOS "Big Sur", This is the code:</pre>



<pre id="block-81379f04-36aa-447a-b275-7bb827256e4e" class="wp-block-preformatted"><code>from tkinter import * </code>
<code>window = Tk() </code>
<code>window.mainloop()</code></pre>



<hr class="wp-block-separator"/>



<p id="block-3cbf8df6-567c-4efc-b697-bd2c9cf4cca8">error message:</p>



<pre class="wp-block-preformatted">macOS 11 or later required</pre>



<hr class="wp-block-separator"/>



<p>runtime screen:</p>



<figure class="wp-block-image size-large"><img decoding="async" width="763" height="480" src="https://stackoverflow.max-everyday.com/wp-content/uploads/2020/12/131669037_892507361490221_4292080155450641838_n.png" alt="" class="wp-image-3648" srcset="https://stackoverflow.max-everyday.com/wp-content/uploads/2020/12/131669037_892507361490221_4292080155450641838_n.png?v=1608742461 763w, https://stackoverflow.max-everyday.com/wp-content/uploads/2020/12/131669037_892507361490221_4292080155450641838_n-600x377.png?v=1608742461 600w" sizes="(max-width: 763px) 100vw, 763px" /></figure>



<hr class="wp-block-separator"/>



<p>網傳解法：</p>



<p>This is an issue in the way&nbsp;<code>brew</code>&nbsp;installs Python (<a href="https://bugs.python.org/issue42480">source</a>). If you install Python directly via the official installer&nbsp;<a href="https://www.python.org/downloads/mac-osx/">here</a>&nbsp;then&nbsp;<code>tkinter</code>&nbsp;should work as expected.</p>



<p>重新下載官方的Python，下載用網址：<br><a href="https://www.python.org/downloads/">https://www.python.org/downloads/</a></p>



<p>會下載檔案：python-3.x.x-macosx1x.x.pkg, 點2下即可開始安裝 python為新的版本。</p>



<hr class="wp-block-separator"/>



<h2 class="wp-block-heading">相關網頁</h2>



<p>Interpreter crashes trying to use tkinter library<br><a href="https://stackoverflow.com/questions/65315077/interpreter-crashes-trying-to-use-tkinter-library">https://stackoverflow.com/questions/65315077/interpreter-crashes-trying-to-use-tkinter-library</a></p>



<p>Python Tkinter crashes on macOS 11.1 beta<br><a href="https://bugs.python.org/issue42480">https://bugs.python.org/issue42480</a></p>
]]></content:encoded>
					
					<wfw:commentRss>https://stackoverflow.max-everyday.com/2020/12/tkinter-show-error-macos-11-or-later-required/feed/</wfw:commentRss>
			<slash:comments>0</slash:comments>
		
		
			</item>
		<item>
		<title>How to find the real user home directory using Python?</title>
		<link>https://stackoverflow.max-everyday.com/2020/08/how-to-find-the-real-user-home-directory-using-python/</link>
					<comments>https://stackoverflow.max-everyday.com/2020/08/how-to-find-the-real-user-home-directory-using-python/#respond</comments>
		
		<dc:creator><![CDATA[max-stackoverflow]]></dc:creator>
		<pubDate>Tue, 11 Aug 2020 00:29:07 +0000</pubDate>
				<category><![CDATA[Python筆記]]></category>
		<category><![CDATA[linux]]></category>
		<category><![CDATA[macOS]]></category>
		<category><![CDATA[Python]]></category>
		<guid isPermaLink="false">http://stackoverflow.max-everyday.com/?p=3497</guid>

					<description><![CDATA[在 macOS 的 python 裡直接輸入 ~...]]></description>
										<content:encoded><![CDATA[
<p>在 macOS 的 python 裡直接輸入 ~/Documents/ 這個路徑，是無效的，檢查 path.exists 是 false. 解法：</p>



<pre class="wp-block-preformatted">import os
print(os.path.expanduser('~'))</pre>



<p>You can also query the environment variables for the HOME variable −</p>



<pre class="wp-block-preformatted">import os
print(os.environ['HOME'])</pre>



<p>If you&#8217;re on Python 3.4+, you can also use pathlib module to get the home directory.&nbsp;</p>



<h2 class="wp-block-heading">example</h2>



<pre class="wp-block-preformatted">from pathlib import Path
print(Path.home())</pre>
]]></content:encoded>
					
					<wfw:commentRss>https://stackoverflow.max-everyday.com/2020/08/how-to-find-the-real-user-home-directory-using-python/feed/</wfw:commentRss>
			<slash:comments>0</slash:comments>
		
		
			</item>
		<item>
		<title>在macOS (OSX)上建立APFS的高性能Ramdisk</title>
		<link>https://stackoverflow.max-everyday.com/2020/08/macos-ramdisk/</link>
					<comments>https://stackoverflow.max-everyday.com/2020/08/macos-ramdisk/#respond</comments>
		
		<dc:creator><![CDATA[max-stackoverflow]]></dc:creator>
		<pubDate>Mon, 10 Aug 2020 11:33:28 +0000</pubDate>
				<category><![CDATA[電腦相關應用]]></category>
		<category><![CDATA[macOS]]></category>
		<guid isPermaLink="false">http://stackoverflow.max-everyday.com/?p=3492</guid>

					<description><![CDATA[最近寫的轉檔程式，常讓筆電都熱乎乎，除了大量的C...]]></description>
										<content:encoded><![CDATA[
<p>最近寫的轉檔程式，常讓筆電都熱乎乎，除了大量的CPU運動之外，常時間在執行Disk I/O 也可能是原因之一，CPU 運算不能省，但Disk I/O 可以使用 Ramdisk ，Max 使用的 shell script:</p>



<pre class="wp-block-preformatted">設定Ramdisk大小，單位(MB)
SIZE=512
磁碟名稱
DISKNAME=Ramdisk
當Ramdisk不存在時建立他
if [[ ! -d /Volumes/${DISKNAME} ]]; then
DISK_ID=<code>hdiutil attach -nomount ram://$(( ${SIZE} * 1024 * 1024 / 512 ))</code>
diskutil partitionDisk $DISK_ID GPT APFS "${DISKNAME}" 0
fi
echo "Ramdisk path: /Volumes/${DISKNAME}"</pre>



<hr class="wp-block-separator"/>



<h2 class="wp-block-heading">執行畫面：</h2>



<figure class="wp-block-image size-full"><img loading="lazy" decoding="async" width="726" height="285" src="https://stackoverflow.max-everyday.com/wp-content/uploads/2020/08/Screen-Shot-2020-08-10-at-19.32.29.png?v=1597059191" alt="" class="wp-image-3494" srcset="https://stackoverflow.max-everyday.com/wp-content/uploads/2020/08/Screen-Shot-2020-08-10-at-19.32.29.png?v=1597059191 726w, https://stackoverflow.max-everyday.com/wp-content/uploads/2020/08/Screen-Shot-2020-08-10-at-19.32.29-600x236.png?v=1597059191 600w" sizes="(max-width: 726px) 100vw, 726px" /></figure>



<hr class="wp-block-separator"/>



<h2 class="wp-block-heading">資料來源：</h2>



<p>在macOS (OSX)上建立APFS的高性能Ramdisk<br><a href="https://blog.jhangy.us/post/create-ramdisk-on-macos/">https://blog.jhangy.us/post/create-ramdisk-on-macos/</a></p>
]]></content:encoded>
					
					<wfw:commentRss>https://stackoverflow.max-everyday.com/2020/08/macos-ramdisk/feed/</wfw:commentRss>
			<slash:comments>0</slash:comments>
		
		
			</item>
		<item>
		<title>How to default Python3.8 on my Mac using Homebrew?</title>
		<link>https://stackoverflow.max-everyday.com/2020/07/brew-reinstall-python-3-8/</link>
					<comments>https://stackoverflow.max-everyday.com/2020/07/brew-reinstall-python-3-8/#respond</comments>
		
		<dc:creator><![CDATA[max-stackoverflow]]></dc:creator>
		<pubDate>Tue, 21 Jul 2020 03:56:12 +0000</pubDate>
				<category><![CDATA[Python筆記]]></category>
		<category><![CDATA[電腦相關應用]]></category>
		<category><![CDATA[Debug]]></category>
		<category><![CDATA[macOS]]></category>
		<category><![CDATA[Python]]></category>
		<guid isPermaLink="false">http://stackoverflow.max-everyday.com/?p=3453</guid>

					<description><![CDATA[目前使用的 python3.7 想升級為 pyt...]]></description>
										<content:encoded><![CDATA[
<p>目前使用的 python3.7 想升級為 python3.8, 但使用 brew update 和 brew upgrade 後還是 python 3.7, 解法如下：</p>



<p>If existing symlinks belong to python 3.7 you should unlink them:<br><code>brew unlink python</code></p>



<p>Basically all you need to do:<br><code>brew link --force python@3.8</code></p>



<p>最後下：</p>



<p>brew reinstall python@3.8</p>



<p>就完成了，需要重開機一次，讓系統變數套成新的設定值。</p>



<hr class="wp-block-separator"/>



<p>使用：</p>



<pre class="wp-block-preformatted">brew info python@3.8 </pre>



<p>可以看到目前 python 3.8 出到那一版，執行畫面：</p>



<figure class="wp-block-image size-large"><img loading="lazy" decoding="async" width="798" height="552" src="https://stackoverflow.max-everyday.com/wp-content/uploads/2020/09/Screen-Shot-2020-09-08-at-04.40.18.png" alt="" class="wp-image-3518" srcset="https://stackoverflow.max-everyday.com/wp-content/uploads/2020/09/Screen-Shot-2020-09-08-at-04.40.18.png?v=1599511310 798w, https://stackoverflow.max-everyday.com/wp-content/uploads/2020/09/Screen-Shot-2020-09-08-at-04.40.18-600x415.png?v=1599511310 600w, https://stackoverflow.max-everyday.com/wp-content/uploads/2020/09/Screen-Shot-2020-09-08-at-04.40.18-768x531.png?v=1599511310 768w" sizes="(max-width: 798px) 100vw, 798px" /></figure>



<hr class="wp-block-separator"/>



<p>查看目前 python 執行環境版本的方法：</p>



<pre class="wp-block-preformatted">import sys<br>print(sys.version)</pre>



<p>為什麼需要去查詢呢？因為有些程式會內建python （例如:fontforge)，如果對方包進程式裡的 python 比我們系統的還新，會造成外部的 package 通通是無效的，無法使用我們環境上的 package，造成程式都無法執行，會顯示ModuleNotFoundError: No module named， module不存在。</p>



<hr class="wp-block-separator"/>



<p>取得 Python site-packages directory 的 path:</p>



<pre class="wp-block-preformatted">import site
site.getsitepackages()</pre>



<p>輸出結果：</p>



<pre class="wp-block-preformatted">['/usr/local/Cellar/python@3.8/3.8.5/Frameworks/Python.framework/Versions/3.8/lib/python3.8/site-packages']</pre>



<hr class="wp-block-separator"/>



<p>如果遇到 FontForge 執行外部python 檔案，顯示 module 不存在，請先找出你的系統裡 python package 的路徑，再把 site-packages 複製一份到 FontForge 的目錄下，例如：</p>



<p>cp -r /usr/local/Cellar/python@3.8/3.8.5/Frameworks/Python.framework/Versions/3.8/lib/python3.8/site-packages/* /Applications/FontForge.app/Contents/Resources/opt/local/lib/python3.8/site-packages</p>
]]></content:encoded>
					
					<wfw:commentRss>https://stackoverflow.max-everyday.com/2020/07/brew-reinstall-python-3-8/feed/</wfw:commentRss>
			<slash:comments>0</slash:comments>
		
		
			</item>
	</channel>
</rss>
