• bennr01

    @JonB said:

         data=read(f)
    

    Shouldn't it be f.read()?

    I have to find all the numerical values in that text file and compute their sum. How can I do this in Pythonista?

    Assuming each line has exactly one numerical value:

    
    def read_ints_from_file(filepath):
        """
        Read integers from file path filepath.
        """
        values = []
        # open file read-only
        with open(filepath, "r") as fin:
            # read file line by line
            for line in fin:
                # remove any leading/trailing whitespace characters and convert to integer
                v = int(line.strip())
                values.append(v)
        return values
    
    # example usage. sum() calculates the sum of the argument(s)
    print(sum(read_ints_from_file("path/to/textfile.txt")))
    
    

    If the file contains text other than the numbers, you should look into regular expressions (using re) to find the values.

    posted in Pythonista read more
  • bennr01

    /private/var/mobile/Containers/Shared/AppGroup/05D14C00-CCAC-4E98-A3CC-96C6944B8534/Pythonista3/Documents/site-packages/xmlrpc/__init__.py

    Did you install this package using the -6 parameter or did you use an outdated StaSh version for this installation? Normally, packages should now be installed only in site-package-3 or site-packages-2 depending on the python version, but it seems like xmlrpc is installed in site-packages...

    @JonB said:

    @bennr01 -- probably need to add xmlrpc to the blacklist...

    It seems like in this case xmlrpc is provided by the future package.

    posted in Pythonista read more
  • bennr01

    @mikael said:

    @bennr01, a big thank you! for all you do to keep us stashed & pipped.

    It's always a pleasure. Though in this case, the fix was made by yjqiang.

    posted in Pythonista read more
  • bennr01

    After looking into this issue for a bit, it seems like the same bug as in Issue #364. This should have been fixed 12 months ago, just a month after the latest version bump for master. So it is possible that you have a version installed before that version bump.

    So, since it seems like the master branch became a bit outdated,I just merged 152 commits from dev into master. This should include the fix as well as a version bump, so could you please try another selfupdate?

    posted in Pythonista read more
  • bennr01

    would appreciate any hints on how to debug this?

    In general, stashconf py_traceback 1, stashconf py_pdb 1 and pip --verbose install pythonista-gestures.

    I just tried and could not replicate the error (it installs successfully).

    Error matches a stash issue.

    I think that one is a different issue. StaSh pip has two installers: one for source install (via setup.py) and one for wheels (.whl). The linked issue was regarding the source install, while this issue is with wheel installations. Also, I think we already fixed the linked issue, but I am not sure...

    posted in Pythonista read more
  • bennr01

    pip -6 install <package> should work.

    posted in Pythonista read more
  • bennr01

    stash: <class 'SyntaxError'>: invalid syntax (pip.py, line 2)
    Traceback (most recent call last):
    File "/private/var/mobile/Containers/Shared/AppGroup/F47C5835-515B-4C73-93FB-38B132E4B000/Pythonista3/Documents/site-packages/stash/system/shruntime.py", line 545, in exec_py_file
    code = compile(content, file_path, "exec", dont_inherit=True)
    File "pip.py", line 2
    python -m pip install SomePackage
    ^
    SyntaxError: invalid syntax

    It seems like StaSh is trying to execute the wrong file. You most likely have a file named pip.py in your current directory. Try executing which pip | xargs rm to remove the wrong file.

    posted in Pythonista read more
  • bennr01

    @JonB said:

    @bennr01 shouldn't he use
    selfupdate -f bennrr01:dev

    It is not important in this case. bennr01:dev is only 10 commits ahead of dev and the only change relevant for pip fixed an AttributeError in certain edge cases.

    posted in Pythonista read more
  • bennr01

    @birkicht I just tried and was able to successfully install colour. The error message you posted indicates that the file $STASH_ROOT/bin/pip.py is damaged (python cant parse it's contents). We have tests for the github repo, so we know that pip.py in the repo is working correctly. So the only other option I can think of is that StaSh tries to execute the wrong file.

    To test this, could you please do the following:

    1. execute stashconf py_traceback 1. This will enable full tracebacks.
    2. execute which pip and post the output of this command here. This will tell us which file StaSh tries to execute. If you have a file named pip.py in your current directoy, this could cause the issues.
    3. execute pip --verbose install colour annd post the output of this command here. This will show more output.

    posted in Pythonista read more
  • bennr01

    Hi,

    maybe your stash install is broken. Try updating to the latest version using selfupdate -f dev.

    posted in Pythonista read more

Internal error.

Oops! Looks like something went wrong!