omz:forum

    • Register
    • Login
    • Search
    • Recent
    • Popular

    Welcome!

    This is the community forum for my apps Pythonista and Editorial.

    For individual support questions, you can also send an email. If you have a very short question or just want to say hello — I'm @olemoritz on Twitter.


    Installing new modules with distutils fails

    Pythonista
    10
    18
    13772
    Loading More Posts
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes
    Reply
    • Reply as topic
    Log in to reply
    This topic has been deleted. Only users with topic management privileges can see it.
    • Proxy
      Proxy last edited by

      Hello everyone

      I'm working on another pip module for Pythonista. It's all done. Searching, downloanding, unziping. But the last step fails. I can't get to work setup() function.

      ImportError: No module named _osx_support
      

      Google tells nothing wise. Any ideas?

      1 Reply Last reply Reply Quote 0
      • briarfox
        briarfox last edited by

        Anyone ever figure this out?

        1 Reply Last reply Reply Quote 0
        • JadedTuna
          JadedTuna last edited by

          @briarfox, I am not sure if this is possible. I think _osx_support is a builtin module in Python on Mac. I will do some research, if I have free time :)

          You can try manually copying folder with python scripts to ~/Documents/site-packages

          1 Reply Last reply Reply Quote 0
          • briarfox
            briarfox last edited by

            @ShadowSlayer Thanks, Yeah I've always just copied over to site-packages but I'd like to learn to use distutils and how to properly setup packages. If you find anything please share!

            1 Reply Last reply Reply Quote 0
            • briarfox
              briarfox last edited by

              @ShadowSlayer I loaded osx_support.py to see what happens. Looks like distutils cant get the correct platform.

              <pre>
              Traceback (most recent call last):
              File "/var/mobile/Applications/149E4C21-2F92-4712-BAC6-151A171C6687/Documents/Projects/Test_Setup/setup.py", line 15, in <module>
              description='<Short Description>',
              File "/var/mobile/Applications/149E4C21-2F92-4712-BAC6-151A171C6687/Pythonista.app/pylib/distutils/core.py", line 125, in setup
              dist.parse_config_files()
              File "/var/mobile/Applications/149E4C21-2F92-4712-BAC6-151A171C6687/Pythonista.app/pylib/distutils/dist.py", line 381, in parse_config_files
              filenames = self.find_config_files()
              File "/var/mobile/Applications/149E4C21-2F92-4712-BAC6-151A171C6687/Pythonista.app/pylib/distutils/dist.py", line 345, in find_config_files
              check_environ()
              File "/var/mobile/Applications/149E4C21-2F92-4712-BAC6-151A171C6687/Pythonista.app/pylib/distutils/util.py", line 185, in check_environ
              os.environ['PLAT'] = get_platform()
              File "/var/mobile/Applications/149E4C21-2F92-4712-BAC6-151A171C6687/Pythonista.app/pylib/distutils/util.py", line 102, in get_platform
              distutils.sysconfig.get_config_vars(),
              File "/var/mobile/Applications/149E4C21-2F92-4712-BAC6-151A171C6687/Pythonista.app/pylib/distutils/sysconfig.py", line 502, in get_config_vars
              func()
              File "/var/mobile/Applications/149E4C21-2F92-4712-BAC6-151A171C6687/Pythonista.app/pylib/distutils/sysconfig.py", line 400, in _init_posix
              raise DistutilsPlatformError(my_msg)
              DistutilsPlatformError: invalid Python installation: unable to open /var/mobile/Applications/lib/python2.7/config/Makefile (No such file or directory)

              </pre>

              1 Reply Last reply Reply Quote 0
              • Kenbo01
                Kenbo01 last edited by

                I had this issue last night while trying to get Jinja2 working with Pythonista. I succeeded by stubbing out the function in dist tools and getting it to drop out to the default platform.

                So I got Jinja2, unidecode, slugify and nvd3 working.

                1 Reply Last reply Reply Quote 0
                • Moe
                  Moe last edited by

                  @Kenbo01 How did you that/What exactly did you do? I would like to hack it working as well.

                  1 Reply Last reply Reply Quote 0
                  • TheWizza
                    TheWizza last edited by

                    @Kenbo01 Way to leave us hangin'... It's all good, I'll check back in another year-and-a-half.

                    1 Reply Last reply Reply Quote 0
                    • ccc
                      ccc last edited by

                      Jinja2 v2.7 is bundled into Pythonista v1.6 beta.

                      1 Reply Last reply Reply Quote 0
                      • wradcliffe
                        wradcliffe last edited by

                        I was waiting to see what @Kenbo01 was doing with Jinja2, unidecode, slugify and nvd3 in Pythonista. Probably just a another very complicated pie chart generator that could be written in 10 lines of simple Python.

                        1 Reply Last reply Reply Quote 0
                        • TheWizza
                          TheWizza last edited by

                          I've kinda got the feeling we won't be hearing from @Kenbo01 anytime soon. If anyone would like to try help us noobians figure out the stub out process, you can find stubout.py at https://code.google.com/p/pymox/source/browse/trunk/stubout.py?r=49. I've been running into the same error message as @Proxy when trying to run larger modules' setup files. Thus far, I've been able to avoid this whole process with smaller modules such as pyperclip by moving them to the site packages directory, but it seems like the whole setup process is unavoidable when trying to access larger modules such as muntjac and Kivy. Any help on is subject would be greatly appreciated!

                          1 Reply Last reply Reply Quote 0
                          • JonB
                            JonB last edited by

                            Guys, just use stash. The pip module of stash is reasonably good, considering the limitations of this platform. This at least automates the process of copying files into site-packages.

                            1 Reply Last reply Reply Quote 0
                            • JonB
                              JonB last edited by

                              By the way:
                              it should be reiterated: modules that require cython cannot be installed in pythonista. So Kivy is out.

                              As for muntjac, see http://omz-forums.appspot.com/pythonista/post/4519765884272640

                              1 Reply Last reply Reply Quote 0
                              • TheWizza
                                TheWizza last edited by

                                @Jon B, thanks for all the help. Trust me, I would love to use StaSh, but unfortunately I'm not too familiar with shell languages. I'm pretty much coming from a self-taught web developer background, and Python is actually the first official high-level language I've tried to pick up outside of HTML/CSS/JavaScript. In fact, this is day two of my Python journey. Not having much luck either. I can't even figure out how to run scripts from the Pythonista command line lol. It may take a few days, but I'm sure I'll get it figured out!

                                1 Reply Last reply Reply Quote 0
                                • JonB
                                  JonB last edited by

                                  The pythonista commandline isn't really for running scripts.
                                  (if you use stash, you can run scripts from the commandline).

                                  You can run scripts from the editor, by pressing play.
                                  Or, add to the action menu.

                                  1 Reply Last reply Reply Quote 0
                                  • TheWizza
                                    TheWizza last edited by

                                    @Jon B, yeah that's what I kinda figured. I was able to run across @briarfox's python_run.py which is exactly what I needed. I appreciate all the help.

                                    For anyone in the future who may be running into similar issues, this method has worked for me:
                                    <pre>

                                    1. Search for and download modules using pipista:

                                      • import pipista from the console (make sure it is located in the 'site packages' dir)

                                      • Search for modules using pipista.pypi_search('module_name’)

                                      • Download modules using pipista.pypi_download('module_name')

                                        pipista.py info - http://omz-forums.appspot.com/pythonista/post/6400412475195392

                                    2. Unzip/untar with StaSh:

                                      • Locate directory of zip file (default location is ~\Documents)
                                        • Change directories with the following commands:
                                        • cd directory_name
                                          • examples (don't type the $ symbol):
                                          • $ cd \downloads
                                          • $ cd "\Zip Files" (for directory names with two words separated by a space)
                                        • Go back one directory:
                                          • $ cd ..
                                        • Go back to parent directory:
                                          • $ cd
                                      • Extract files with the following commands:
                                        • .zip files:
                                          • $ unzip module_name.zip
                                        • .gz files:
                                          • $ ungzip module_name.gz
                                        • .tar files:
                                          • $ untar module_name.tar
                                      StaSh - https://omz-forums.appspot.com/pythonista/post/5894157600030720
                                      
                                    3. Read the tutorial linked below to learn how to install via StaSh:

                                      • Tutorial - http://omz-software.com/pythonista/docs/ios/bottle/tutorial.html
                                      • The actual command for installing the module will look like this:
                                        • $ pip install module_name
                                    4. Done.
                                      </pre>

                                    Hope this helps. If anyone has a better method, please feel free to comment below. It literally took me two days to figure that shit out. Hopefully this will save somebody some time in the future.

                                    Holla from the past.

                                    1 Reply Last reply Reply Quote 0
                                    • oefe186
                                      oefe186 last edited by

                                      @TheWizza, these manual steps are unnecessary.

                                      Using stash,

                                      pip install module_name
                                      

                                      is all you need. Pip does the searching, downloading and unzipping for you.

                                      Pip can also search for modules (if you don't know the exact name), update modules, install a specific version, and more. as with any stash command, you can use

                                      pip -h
                                      

                                      or

                                      man pip
                                      

                                      to learn about pip's capabilities.

                                      1 Reply Last reply Reply Quote 0
                                      • TheWizza
                                        TheWizza last edited by

                                        @oefe, you are truly amazing, my friend! Big ups to both you and @Jon B!

                                        1 Reply Last reply Reply Quote 0
                                        • First post
                                          Last post
                                        Powered by NodeBB Forums | Contributors