How do I install third party modules in the Mu Editor?

4.5k Views Asked by At

I am trying to install third party modules in the Mu Editor on my Mac OS and I am following the instructions on "Automate the boring stuff with Python" (here is the link to the instructions I am following: https://automatetheboringstuff.com/2e/appendixa/)

I am now trying to install the same modules I just install in Python 3 in my Mu Editor as well, so from the terminal I went to the folder where the file called "automate-mac-requirements.txt" is located and I run the command below:

pip3 install –r automate-mac-requirements.txt --target /Applications/ mu-editor.app/Contents/Resources/app_packages

This is the error message I got and where I need your help (I suppose I need help on understanding how to install third party modules on Python and the Mu Editor):

ERROR: Command errored out with exit status 1:
 command: /Library/Frameworks/Python.framework/Versions/3.8/bin/python3.8 -c 'import sys, setuptools, tokenize; sys.argv[0] = '"'"'/private/var/folders/7f/bd6jh1p12db7gggdnzvrsbhw0000gn/T/pip-install-eszre7tv/pyobjc-core/setup.py'"'"'; __file__='"'"'/private/var/folders/7f/bd6jh1p12db7gggdnzvrsbhw0000gn/T/pip-install-eszre7tv/pyobjc-core/setup.py'"'"';f=getattr(tokenize, '"'"'open'"'"', open)(__file__);code=f.read().replace('"'"'\r\n'"'"', '"'"'\n'"'"');f.close();exec(compile(code, __file__, '"'"'exec'"'"'))' egg_info --egg-base /private/var/folders/7f/bd6jh1p12db7gggdnzvrsbhw0000gn/T/pip-pip-egg-info-6rm0vgka
     cwd: /private/var/folders/7f/bd6jh1p12db7gggdnzvrsbhw0000gn/T/pip-install-eszre7tv/pyobjc-core/
Complete output (49 lines):
running egg_info
creating /private/var/folders/7f/bd6jh1p12db7gggdnzvrsbhw0000gn/T/pip-pip-egg-info-6rm0vgka/pyobjc_core.egg-info
writing include/pyobjc-compat.h to /private/var/folders/7f/bd6jh1p12db7gggdnzvrsbhw0000gn/T/pip-pip-egg-info-6rm0vgka/pyobjc_core.egg-info/include/pyobjc-compat.h
writing include/pyobjc-api.h to /private/var/folders/7f/bd6jh1p12db7gggdnzvrsbhw0000gn/T/pip-pip-egg-info-6rm0vgka/pyobjc_core.egg-info/include/pyobjc-api.h
writing /private/var/folders/7f/bd6jh1p12db7gggdnzvrsbhw0000gn/T/pip-pip-egg-info-6rm0vgka/pyobjc_core.egg-info/PKG-INFO
writing dependency_links to /private/var/folders/7f/bd6jh1p12db7gggdnzvrsbhw0000gn/T/pip-pip-egg-info-6rm0vgka/pyobjc_core.egg-info/dependency_links.txt
writing namespace_packages to /private/var/folders/7f/bd6jh1p12db7gggdnzvrsbhw0000gn/T/pip-pip-egg-info-6rm0vgka/pyobjc_core.egg-info/namespace_packages.txt
writing top-level names to /private/var/folders/7f/bd6jh1p12db7gggdnzvrsbhw0000gn/T/pip-pip-egg-info-6rm0vgka/pyobjc_core.egg-info/top_level.txt
writing manifest file '/private/var/folders/7f/bd6jh1p12db7gggdnzvrsbhw0000gn/T/pip-pip-egg-info-6rm0vgka/pyobjc_core.egg-info/SOURCES.txt'
xcode-select: error: tool 'xcodebuild' requires Xcode, but active developer directory '/Library/Developer/CommandLineTools' is a command line tools instance
/private/var/folders/7f/bd6jh1p12db7gggdnzvrsbhw0000gn/T/pip-install-eszre7tv/pyobjc-core/setup.py:369: DeprecationWarning: 'U' mode is deprecated
  with open(os.path.join('Modules/objc/', os.path.basename(basename)), 'rU') as fp:
Traceback (most recent call last):
  File "<string>", line 1, in <module>
  File "/private/var/folders/7f/bd6jh1p12db7gggdnzvrsbhw0000gn/T/pip-install-eszre7tv/pyobjc-core/setup.py", line 692, in <module>
    setup(
  File "/Library/Frameworks/Python.framework/Versions/3.8/lib/python3.8/site-packages/setuptools/__init__.py", line 165, in setup
    return distutils.core.setup(**attrs)
  File "/Library/Frameworks/Python.framework/Versions/3.8/lib/python3.8/distutils/core.py", line 148, in setup
    dist.run_commands()
  File "/Library/Frameworks/Python.framework/Versions/3.8/lib/python3.8/distutils/dist.py", line 966, in run_commands
    self.run_command(cmd)
  File "/Library/Frameworks/Python.framework/Versions/3.8/lib/python3.8/distutils/dist.py", line 985, in run_command
    cmd_obj.run()
  File "/private/var/folders/7f/bd6jh1p12db7gggdnzvrsbhw0000gn/T/pip-install-eszre7tv/pyobjc-core/setup.py", line 361, in run
    egg_info.egg_info.run(self)
  File "/Library/Frameworks/Python.framework/Versions/3.8/lib/python3.8/site-packages/setuptools/command/egg_info.py", line 297, in run
    self.find_sources()
  File "/Library/Frameworks/Python.framework/Versions/3.8/lib/python3.8/site-packages/setuptools/command/egg_info.py", line 304, in find_sources
    mm.run()
  File "/Library/Frameworks/Python.framework/Versions/3.8/lib/python3.8/site-packages/setuptools/command/egg_info.py", line 535, in run
    self.add_defaults()
  File "/Library/Frameworks/Python.framework/Versions/3.8/lib/python3.8/site-packages/setuptools/command/egg_info.py", line 571, in add_defaults
    sdist.add_defaults(self)
  File "/Library/Frameworks/Python.framework/Versions/3.8/lib/python3.8/distutils/command/sdist.py", line 228, in add_defaults
    self._add_defaults_ext()
  File "/Library/Frameworks/Python.framework/Versions/3.8/lib/python3.8/distutils/command/sdist.py", line 311, in _add_defaults_ext
    build_ext = self.get_finalized_command('build_ext')
  File "/Library/Frameworks/Python.framework/Versions/3.8/lib/python3.8/distutils/cmd.py", line 299, in get_finalized_command
    cmd_obj.ensure_finalized()
  File "/Library/Frameworks/Python.framework/Versions/3.8/lib/python3.8/distutils/cmd.py", line 107, in ensure_finalized
    self.finalize_options()
  File "/private/var/folders/7f/bd6jh1p12db7gggdnzvrsbhw0000gn/T/pip-install-eszre7tv/pyobjc-core/setup.py", line 532, in finalize_options
    self.sdk_root = subprocess.check_output(
  File "/Library/Frameworks/Python.framework/Versions/3.8/lib/python3.8/subprocess.py", line 411, in check_output
    return run(*popenargs, stdout=PIPE, timeout=timeout, check=True,
  File "/Library/Frameworks/Python.framework/Versions/3.8/lib/python3.8/subprocess.py", line 512, in run
    raise CalledProcessError(retcode, process.args,
subprocess.CalledProcessError: Command '['/usr/bin/xcodebuild', '-version', '-sdk', 'macosx', 'Path']' returned non-zero exit status 1.
----------------------------------------

ERROR: Command errored out with exit status 1: python setup.py egg_info Check the logs for full command output.

4

There are 4 best solutions below

0
On

I am also reading automateTheBoringStuff2.

I installed each package one by one. For example the module pyautogui:

pip3 install pyautogui --target /Applications/mu-editor.app/Contents/Resources/app_packages

Make sure you specify the version you would like to install.

Running python 3.9, I had problems to install the module pyobjc. Make sure you install the latest version (which is version 7.1 as of January 27, 2021).

0
On

I had the same issue, and here is the easiest way to solve it:

  • click on the settings icon (at the bottom right) on the mu-editor
  • click on the "Third Party Packages" tab
  • on a new line in the text box, write the name of the package you wish to install
  • and then click OK

the Third Party Package then installs on mu's virtual environment

This is a simple support for third party packages in mu-editor. More details here

0
On

I was having the same issue trying to install all the packages at once with the resources provided by the book. What worked for me was to separately install the module I needed.

I did the following:

  1. Separately download the module you need, in my case 'pyperclip', at pypi.org.
  2. Move the downloaded folder, in my case 'pyperclip-1.8.2', into /Applications/mu-editor.app/Contents/Resources/app_packages (I didn't have the last folder 'app_packages', so I created it myself which worked).
  3. Open a terminal window from the folder /Applications/mu-editor.app/Contents/Resources/app_packages.
  4. Type: pip3 install pyperclip.
  5. Done! Now it works, at least for me it did.

I'm not sure if this works for any of the other modules since i'm not that far yet.

0
On

I believe you need to install this using the command prompt window, not MU. I'm also currently running into issues installing these via that window though.