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.


    Regex and numpy question

    Pythonista
    4
    14
    5607
    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.
    • pulbrich
      pulbrich last edited by

      If I run

      import re
      
      print(re)
      
      

      I get

      <module 're' from '/var/containers/Bundle/Application/7F183C05-845F-47C3-93D3-533E30766BBB/Pythonista3.app/Frameworks/Py3Kit.framework/pylib/re.py'>
      

      which is what it should be. Could you try these two lines of code and show the console output?

      puckypuck 1 Reply Last reply Reply Quote 0
      • puckypuck
        puckypuck @pulbrich last edited by

        @pulbrich

        I get the same
        module 're' from '/var/containers/Bundle/Application/

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

          Then you can use re, which is the Pythonista supplied regex module.

          puckypuck 1 Reply Last reply Reply Quote 0
          • puckypuck
            puckypuck @pulbrich last edited by

            @pulbrich

            Ok thanks for the support.
            I dont know what i do wrong, trying running the script and get error all the time

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

              I have Pythonista v3.2 , iPhone v13.3.1,
              re works perfect.

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

                @puckypuck can you post the full traceback of the problem you get, along with the code?

                If you have tried to install pandas, and numpy, etc, you need to go clean out your site packages folder.

                In your original code you wrote

                import regex as re

                Which is not correct -- you just want import re

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

                  @JonB

                  Ok i cleaned my side packages.

                  ============================= test session starts ==============================
                  platform ios -- Python 3.6.1, pytest-3.0.5, py-1.4.32, pluggy-0.4.0 -- /private/var/containers/Bundle/Application/79823AB3-8B78-4BFE-85AA-07A6911F8A59/Pythonista3.app/Pythonista3
                  rootdir: /private/var/mobile/Containers/Shared/AppGroup/09B9F2A0-A8A6-48F9-A9FF-5270C93BC17E/Pythonista3/Documents, inifile:
                  collecting ... collected 0 items / 1 errors

                  generated xml file: /private/var/mobile/Containers/Shared/AppGroup/09B9F2A0-A8A6-48F9-A9FF-5270C93BC17E/Pythonista3/Documents/.pythonista_pytest_log.xml
                  ==================================== ERRORS ====================================
                  __________________________ ERROR collecting test2.py ___________________________
                  ImportError while importing test module '/private/var/mobile/Containers/Shared/AppGroup/09B9F2A0-A8A6-48F9-A9FF-5270C93BC17E/Pythonista3/Documents/test2.py'.
                  Hint: make sure your test modules/packages have valid Python names.
                  Traceback:
                  test2.py:5: in <module>
                  from binance.client import Client
                  site-packages-3/binance/client.py:8: in <module>
                  from .helpers import date_to_milliseconds, interval_to_milliseconds
                  site-packages-3/binance/helpers.py:3: in <module>
                  import dateparser
                  site-packages-3/dateparser/init.py:4: in <module>
                  from .date import DateDataParser
                  site-packages-3/dateparser/date.py:10: in <module>
                  import regex as re
                  E ModuleNotFoundError: No module named 'regex'
                  !!!!!!!!!!!!!!!!!!! Interrupted: 1 errors during collection !!!!!!!!!!!!!!!!!!!!
                  =========================== 1 error in 0.96 seconds ============================

                  And here is my code:
                  import matplotlib
                  from matplotlib import pyplot as plt

                  from binance.client import Client
                  import keys

                  Client = Client(apikey,apisecret)

                  klines_df =pd.Dataframe (Client.get_historical_klines("BTCUSDT",Client.KLINE_INTERVAL_1DAY,"1000 days ago UTC"))

                  print(klines_df)

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

                    Looks like binance has non pure dependencies.

                    autobahn==18.7.1
                    certifi==2019.11.28
                    cryptography==2.3
                    dateparser==0.7.0
                    pyOpenSSL==19.0.0
                    requests==2.22.0
                    service-identity==17.0.0
                    Twisted==19.7.0
                    

                    Cryptography is a no.
                    Pyopenssl depends on it, though there may be a way to force it to use crypto instead.

                    Requests, you may be able to update, though it can be tricky.

                    Try reinstalling pip install regex. Then try import regex, and make sure that works. regex is pure py, so should work. For quit pythonista and try again.

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

                      This regex is killing me.
                      I have reinstalled pythonista, again the message no module regex.
                      tryed pip install regex and get a setup.py error message

                      Sorry for the many questions, and this is the last time before i give up.

                      [~/Documents]$ pip install regex
                      Querying PyPI ...
                      Downloading package ...
                      Opening: https://files.pythonhosted.org/packages/73/d9/b58289d885180b5d538aa6df07974b5fe6088547ac846c0f76f77259c304/regex-2020.1.8.tar.gz

                      Save as: /private/var/mobile/Containers/Data/Application/E4F4BB3B-DCD1-4E68-9C70-3BE1281A906D/tmp//regex-2020.1.8.tar.gz (681106 bytes)
                      681106 [100.00%]
                      Extracting archive file ...
                      Archive extracted.
                      Running setup file ...
                      WARNING: Extension modules are skipped: [<main.OmniClass object at 0x1155afb38>]
                      PipError('cannot locate source folder/file: /private/var/mobile/Containers/Data/Application/E4F4BB3B-DCD1-4E68-9C70-3BE1281A906D/tmp/2cc8cbdf6ff94fec933154320700e076/regex-2020.1.8/regex.py',)
                      Failed to run setup.py
                      Fall back to directory guessing ...
                      Error: Cannot locate packages. Manual installation required.
                      [~/Documents]$

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

                        Ok, scratch that... I was looking at a different regex on GitHub ... The regex package is
                        https://bitbucket.org/mrabarnett/mrab-regex/

                        And is c code -- thus not supported.

                        A quick skim seems to show that dateparser/regex should work in pypy, and so maybe pythonista, but maybe you need to manually download the package, and just copy into site-packages.

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