Mycroft Community Forum

Cannot get additonal dependencies to work in skill

Hello everyone,

I am having trouble with getting a Mycroft skill with addition python package dependencies to work on my Ubuntu machine (I already read the whole Mycroft skill section on dependencies). I have Mycroft installed and it’s running great. I began the process by creating a Mycroft skill with “msk create”, and the skill shows up in my “skills” folder just fine.
The python package I want to use is “mysql-connector-python” from PyPi.
My main question is how do I set up my development environment to include this mysql dependency?
I have tried the following:
Open the “mySkillName” folder in Pycharm, select python 3.6 as project interpreter, install “mysql-connector-python” in the project, and import “mysql.connector” (which only showed up in the IDE after installing it in the project".
Upon initiating the skill through Mycroft, it doesn’t recognize my input (which it did before I imported “mysql.connector”.
I am not trying to at this moment get my skill accepted onto the Github (I want to test on local machine), so I don’t believe simply entering “mysql-connector-python” into a “Manifest.yml” or “Requirements.txt” file will do me any good (I already tried both those).

I hope you understand what I’m asking. apologize if I’m being too vague. I appreciate any help and will gladly elaborate more if needed.

Thank you!

1 Like

I’m not a skill developer, nor a python dev either, but my guess would be putting mysql-connector-python inside a requirements.txt and install the dependency via pip. Surely any proper developer will help you better than me.
Take a look into https://chat.mycroft.ai channel ~skills if nobody answers here. Chat usually is faster than forum to get advice.

2 Likes

Hi there, welcome to the Forums!

Great to hear you are getting started with some Skill development and thanks for highlighting this issue as it definitely isn’t covered in our docs. I’ll be sure to add it this week :slight_smile:

You want to install the Python package in the Mycroft virtual environment. The simplest way to do this is using the helper command mycroft-pip located in mycroft-core/bin/

During installation you may have selected to add this directory to your PATH in which case you can run it from anywhere.

mycroft-pip install mysql-connector-python

If you don’t want to use the helper commands you can do it manually by:

cd ~/mycroft-core        # or whereever you cloned Mycroft-core
source venv-activate.sh  # activate the virtual environment
pip install mysql-connector-python
deactivate               # to exit the virtual environment again

You can also use the pip -r flag to install all of your Skills requirements at once eg:

cd /opt/mycroft/skills/my-skill
mycroft-pip install -r requirements.txt

Thanks again for the great question!

1 Like

Just ran your “mycroft-pip install mysql-connector-python” command and it worked! That package now runs successfully with my skill!
Another question though if you don’t mind:
I’m trying to set up my development environment (Pycharm in this case) for my skill. Upon debugging my “init.py” file though, it tells me that module “mycroft” is not found (image below). I don’t understand how this could be because when I created my Virtualenv in Pycharm, I chose to Inherit global site-packages (which I assumed would include the mycroft module?).
I guess I’m wondering where the mycroft module can be found, so that I can hopefully point my sys.path to it. Or do you know of yet a better way of doing what I’m trying to do?

Thanks again!
Screenshot from 2020-02-19 18-27-52

Hi @UltimateSquid
I dont know PyCharm that much. But I do know a little about debugging. I have been trying to make debug posible for around a year but had bit trouble. But finaly short time ago I figured out how and what should be changed in mycroft-core to make debugging running skills posible.

You cannot just debug a singel file in a skill as it dont run alone. If you want to debug a running skill you hav to debug the skillsservice and attatch to that.
But debugging the skillsservice is a bit more complex than just debug a single pythonfile. But defently posible.

I made a skill that is pending market - Remote debug skill.
What it does is stopping skillservice, set patadious into single thread mode and then start debug adaptor and get that to start skillservice.
Then you can attatch to that debug session and if you have breakpoints set in your skill it will st at that and you can step into the running code.

It works from vscode and Theia IDE, and I guess itt also would work from other IDE’s like PyCharm, but as I dont know PyCharm I cant help on how to do it from that IDE.

Se more about remote debug skill here


Specifik on the setup of remote attatcg

{
        "name": "Python: Remote Attach",
        "type": "python",
        "request": "attach",
        "port": 5678,
        "host": "localhost"
 }

To install remote debug skill you can install that with mycroft-msm by:

mycroft-msm install https://github.com/andlo/remote-debug-skill.git

and after that you start debug adaptor by asking mycroft to do that by:

“Hey mycroft - Run remote debug adaptor”

And then you can see in the cli that he is stopping skillsservice and start again and that patadious is in single mode.

When you dont want to debug anymore you can stop the debug adaptor by saying:

“Hey mycroft - End remote debug adaptor”

And you can se in the CLI taht skillservice is stoped and started and patadious single thrad is false.

When debuging adaptor is active you can se that it is running by

pi@picroft1:/opt/mycroft/skills $ ps ax |grep " -m mycroft.skills"
22034 ?        Rl     0:09 python3 -m ptvsd --host 0.0.0.0 --port 5678 -m mycroft.skills
22138 pts/1    S+     0:00 grep --color=auto  -m mycroft.skills
pi@picroft1:/opt/mycroft/skills $ 

When debug adaptor is not run same command shows:

pi@picroft1:/opt/mycroft/skills $ ps ax |grep " -m mycroft.skills"
21460 pts/1    S+     0:00 grep --color=auto  -m mycroft.skills
28762 pts/10   Sl   575:48 python3 -m mycroft.skills
pi@picroft1:/opt/mycroft/skills $ 

Notise teh difference - mycroft.skills is called from ptvsd when debug is active and not when running normal.

Hope that gets you further, and I would be interesting in hearing on how to setup PyCharm for rempte debuging as PyCharm is a IDE lots of pythonists are using and others could benefit on knowing on how to do remote debug of mycroft.

3 Likes

This is great, thank you for posting this!
To be honest I haven’t had time to try your remote debug skill yet, but when I do I’ll let you know how it goes (as well as if I ever get remote debugging to work within PyCharm).