Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

"Cannot locate s2m files on path." error #1

Closed
champierre opened this issue Nov 22, 2017 · 13 comments
Closed

"Cannot locate s2m files on path." error #1

champierre opened this issue Nov 22, 2017 · 13 comments

Comments

@champierre
Copy link
Contributor

champierre commented Nov 22, 2017

I think I properly followed the installation guide https://mryslab.github.io/s2m/install/.
When I started "s2m", I got "Cannot locate s2m files on path." as below.
What could it be wrong?

I use MacOS Sierra 10.12.6(16G29).

➜  ~ s2m

s2m version 1.03  Copyright(C) 2017 Alan Yorinks  All rights reserved.

Python Version 2.7.14 (default, Sep 25 2017, 09:53:22)
[GCC 4.2.1 Compatible Apple LLVM 9.0.0 (clang-900.0.37)]
Autodetecting serial port. Please wait...
Using COM Port:/dev/tty.usbmodem14612

Cannot locate s2m files on path.
None
@MrYsLab
Copy link
Owner

MrYsLab commented Nov 22, 2017

@champierre Could you please try starting the program with:

s2m -d true

This should provide a path to where the files are thought to be.

If you cd into that directory you should see the s2m files.

Could you please let me know if the files are there or not?

Below is the output on a linux box. It should be very similar for the mac.

afy@afy-VirtualBox:~$ s2m -d true

s2m version 1.01  Copyright(C) 2017 Alan Yorinks  All rights reserved.

Python Version 3.6.0 (default, Jan 11 2017, 14:11:08) 
[GCC 4.8.4]
Autodetecting serial port. Please wait...
Using COM Port:/dev/ttyACM0

Python path = /usr/local/lib/python3.6/site-packages/s2m
afy@afy-VirtualBox:~$ cd /usr/local/lib/python3.6/site-packages/s2m
afy@afy-VirtualBox:/usr/local/lib/python3.6/site-packages/s2m$ ls
__init__.py        __pycache__         s2m.py
micro_bit_scripts  s2m_http_server.py  scratch_files
afy@afy-VirtualBox:/usr/local/lib/python3.6/site-packages/s2m$ 

@MrYsLab
Copy link
Owner

MrYsLab commented Nov 23, 2017

@champierre An additional thought. Did you install using pip AND sudo? You can find instructions at https://mryslab.github.io/s2m/install/#installing-s2m.

@champierre
Copy link
Contributor Author

@MrYsLab I got the following error message when I ran "s2m -d true".
It looks like the initial communication between s2m and micro:bit was successful because it shows the version info of s2mb.py after I flashed the latest script to micro:bit.

➜  ~ s2m -d true

s2m version 1.05  Copyright(C) 2017 Alan Yorinks  All rights reserved.

Python Version 2.7.14 (default, Sep 25 2017, 09:53:22)
[GCC 4.2.1 Compatible Apple LLVM 9.0.0 (clang-900.0.37)]
Autodetecting serial port. Please wait...
Using COM Port:/dev/tty.usbmodem14612

s2mb Version: s2mb.py Version 1.04 23 November 2017

Traceback (most recent call last):
  File "/usr/local/bin/s2m", line 11, in <module>
    sys.exit(main())
  File "/usr/local/lib/python2.7/site-packages/s2m/s2m.py", line 574, in main
    base_path=user_base_path, display_base_path=display)
  File "/usr/local/lib/python2.7/site-packages/s2m/s2m.py", line 189, in __init__
    self.find_base_path()
  File "/usr/local/lib/python2.7/site-packages/s2m/s2m.py", line 241, in find_base_path
    print('Python path = ' + self.base_path)
TypeError: cannot concatenate 'str' and 'NoneType' objects

@MrYsLab
Copy link
Owner

MrYsLab commented Nov 25, 2017

I just released v 1.06. Please try updating to this release.

If you are still having issues, please look at the contents of
/usr/local/lib/python2.7/site-packages/s2m/

You should see s2m.py. If you do, do you also see a scratch_files directory?

If not, does the following directory exist and does it contain a scratch_files directory:
/usr/local/lib/python2.7/dist-packages/s2m

Until we have things sorted out with your existing problem, you can try running things manually by following the instructions at this link: https://mryslab.github.io/s2m/usage/#manually-starting-s2m-and-scratch

Please let me know what you see in the directories and if you try the manual start, does that work for you.
Thanks

@champierre
Copy link
Contributor Author

champierre commented Nov 27, 2017

After I updated to v 1.06, I still see the same error.

Under /usr/local/lib/python2.7/site-packages/s2m/, both s2m.py and scratch_files exists.

➜  ~ cd /usr/local/lib/python2.7/site-packages/s2m/
➜  s2m ls
__init__.py         micro_bit_scripts   s2m.pyc             s2m_http_server.pyc
__init__.pyc        s2m.py              s2m_http_server.py  scratch_files
➜  s2m

I followed the manual install, but got the same error:

➜  ~ s2m -c no_client

s2m version 1.06  Copyright(C) 2017 Alan Yorinks  All rights reserved.

Python Version 2.7.14 (default, Sep 25 2017, 09:53:22)
[GCC 4.2.1 Compatible Apple LLVM 9.0.0 (clang-900.0.37)]
Autodetecting serial port. Please wait...
Using COM Port:/dev/tty.usbmodem14612

s2mb Version: s2mb.py Version 1.04 23 November 2017

Cannot locate s2m files on path.
Python path = None

@MrYsLab
Copy link
Owner

MrYsLab commented Nov 27, 2017

I have released version 1.07 that should now allow you to manually start s2m and scratch. Please give that a try.

I would also like to understand what is going on with the path so you do not have to start manually. Could you please try starting s2m with the sudo command:

sudo s2m

Please let me know if that works. If not, could you please running the following Python script and attach the output here.
Thanks.

import os
import sys


def find_base_path():
    """
    Look for the path to the Scratch operational files.
    Update self.base_path with the path
    """

    base_path = None
    # get all the paths
    path = sys.path

    # get the prefix
    prefix = sys.prefix
    for p in path:
        # make sure the prefix is in the path to avoid false positives
        if prefix in p:
            print(p)
            # look for the configuration directory
            s_path = p + '/s2m'
            if os.path.isdir(s_path):
                # found it, set the base path
                base_path = p + '/s2m'

    if not base_path:
        print('Cannot locate s2m files on path.')
        print('Python path = ' + str(base_path))
        sys.exit(0)

    else:
        print('Python path = ' + str(base_path))
        sys.exit(0)

find_base_path()

@champierre
Copy link
Contributor Author

Version 1.07 works fine if I do manual install.
Now I can use s2m.
This is great.

Running "sudo s2m" gives the same "Cannot locate s2m files on path." error.

Here is the output that your debug script gives.

➜  ~ python test.py
/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python27.zip
/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7
/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/plat-darwin
/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/plat-mac
/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/plat-mac/lib-scriptpackages
/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/lib-tk
/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/lib-old
/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/lib-dynload
/System/Library/Frameworks/Python.framework/Versions/2.7/Extras/lib/python
/System/Library/Frameworks/Python.framework/Versions/2.7/Extras/lib/python/PyObjC
Cannot locate s2m files on path.
Python path = None

@MrYsLab
Copy link
Owner

MrYsLab commented Nov 27, 2017

I am glad that it is working manually. I don't know why /usr/local/lib/python2.7/site-packages/s2m/
does not appear in the list you printed out. There is obviously something different about the Mac and I will have to investigate this.

You could try using the -b option to see if Scratch will auto launch:

s2m -b /usr/local/lib/python2.7/site-packages/s2m

@MrYsLab
Copy link
Owner

MrYsLab commented Nov 27, 2017

This may help. If you open up a command window, the type:

export PYTHONPATH=$PYTHONPATH:/usr/local/lib/python2.7/site-packages

And then type s2m, hopefully this will make things work.
If you have time to try this and it works, I will update the documentation.

Thanks.

@champierre
Copy link
Contributor Author

s2m -b /usr/local/lib/python2.7/site-packages/s2m

works, but I got another error.

/bin/sh: /opt/Scratch 2/bin/Scratch 2: No such file or directory

To run Scratch 2 Offline Editor from terminal on Mac, you need to run:

 /Applications/Scratch\ 2.app/Contents/MacOS/Scratch\ 2

I found that "sys.prefix" returns "/System/Library/Frameworks/Python.framework/Versions/2.7", which is different from s2m location.

So, removing "if prefix in p:" line from your debug script gives the correct python path:

Python path = /usr/local/lib/python2.7/site-packages/s2m

@MrYsLab
Copy link
Owner

MrYsLab commented Nov 27, 2017

Version 1.08 incorporates the paths you mentioned above. Could you please try installing it and let me know if s2m now successfully starts using

s2m

as the command?

Thanks.

@champierre
Copy link
Contributor Author

Yeah!! Everything works perfectly.
Thank you very much for fixing the issue.

➜  ~ s2m

s2m version 1.07  Copyright(C) 2017 Alan Yorinks  All rights reserved.

Python Version 2.7.14 (default, Sep 25 2017, 09:53:22)
[GCC 4.2.1 Compatible Apple LLVM 9.0.0 (clang-900.0.37)]
Autodetecting serial port. Please wait...
Using COM Port:/dev/tty.usbmodem14412

s2mb Version: s2mb.py Version 1.04 23 November 2017

Auto launching Scratch
Starting HTTP Server!
Use <Ctrl-C> to exit the extension.
Please make sure you save your Scratch project BEFORE pressing Ctrl-C.

@MrYsLab
Copy link
Owner

MrYsLab commented Nov 28, 2017

Great!!!! Thanks for your patience and help.

@MrYsLab MrYsLab closed this as completed Nov 28, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants