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 debug Python skill locally due to missing site.getsitepackges() in virtualenvs #27

Closed
joerg86 opened this issue Aug 11, 2020 · 3 comments
Labels
bug Something isn't working

Comments

@joerg86
Copy link

joerg86 commented Aug 11, 2020

Describe the bug

I'm getting this error when I want to test my Python based skill locally by clickung Run -> Start Debugging:

error

To Reproduce

I followed the instructions to test my Python based skill locally:
https://developer.amazon.com/de-DE/docs/alexa/ask-toolkit/vs-code-ask-skills.html#test

The error pops up when I click Run -> Start Debugging.

My virtualenv lives in ./venv and is Python version 3.6.9 on Ubuntu Linux 18.04. The ask-sdk-local-debug package is installed in this venv. It seems that the extensions uses site.getsitepackages() to get the list of installed packages. But that is not available in a virtualenv. This seems to be related:

pypa/virtualenv#737

** launch.json **
{
// Use IntelliSense to learn about possible attributes.
// Hover to view descriptions of existing attributes.
// For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387
"version": "0.2.0",
"configurations": [
{
"name": "Debug Alexa Skill (Python)",
"type": "python",
"request": "launch",
"program": "${command:ask.debugAdapterPath}",
"pythonPath": "${command:python.interpreterPath}",
"args": [
"--accessToken",
"${command:ask.accessToken}",
"--skillId",
"${command:ask.skillIdFromWorkspace}",
"--skillHandler",
"lambda_handler",
"--skillFilePath",
"${workspaceFolder}/lambda/lambda_function.py"
],
"console": "internalConsole"
}
]
}

Extension Logs

[info - 2020-08-11 18:53:16.282Z] log level changed to debug
[debug - 2020-08-11 18:53:23.390Z] Calling method: ask.debugAdapterPath, args: [{"name":"Debug Alexa Skill (Python)","type":"python","request":"launch","program":"${command:ask.debugAdapterPath}","pythonPath":"/home/joerg/iubh_alexa/IUBH/venv/bin/python","args":["--accessToken","${command:ask.accessToken}","--skillId","${command:ask.skillIdFromWorkspace}","--skillHandler","lambda_handler","--skillFilePath","/home/joerg/iubh_alexa/IUBH/lambda/lambda_function.py"],"console":"internalConsole","cwd":"/home/joerg/iubh_alexa/IUBH","envFile":"/home/joerg/iubh_alexa/IUBH/.env","env":{"ELECTRON_RUN_AS_NODE":"1","GTK_CSD":"1","USER":"joerg","LANGUAGE":"de_DE","LC_TIME":"de_DE.UTF-8","XDG_SEAT":"seat0","XDG_SESSION_TYPE":"x11","SSH_AGENT_PID":"4310","SHLVL":"1","HOME":"/home/joerg","DESKTOP_SESSION":"pantheon","QT_STYLE_OVERRIDE":"adwaita","GTK_MODULES":"gail:atk-bridge","XDG_SEAT_PATH":"/org/freedesktop/DisplayManager/Seat0","LC_MONETARY":"de_DE.UTF-8","DBUS_SESSION_BUS_ADDRESS":"unix:path=/run/user/1000/bus","MANDATORY_PATH":"/usr/share/gconf/pantheon.mandatory.path","QT_QPA_PLATFORMTHEME":"gtk3","LOGNAME":"joerg","DEFAULTS_PATH":"/usr/share/gconf/pantheon.default.path","XDG_SESSION_ID":"c2","GDM_LANG":"de_DE","GTK3_MODULES":"pantheon-filechooser-module:pantheon-filechooser-module","PAPERSIZE":"a4","S_COLORS":"auto","LC_ADDRESS":"de_DE.UTF-8","XDG_RUNTIME_DIR":"/run/user/1000","XDG_SESSION_PATH":"/org/freedesktop/DisplayManager/Session0","DISPLAY":":0","LANG":"de_DE.UTF-8","XDG_CURRENT_DESKTOP":"Unity","LC_TELEPHONE":"de_DE.UTF-8","XDG_SESSION_DESKTOP":"pantheon","XAUTHORITY":"/home/joerg/.Xauthority","XDG_GREETER_DATA_DIR":"/var/lib/lightdm-data/joerg","SSH_AUTH_SOCK":"/run/user/1000/keyring/ssh","LC_NAME":"de_DE.UTF-8","SHELL":"/bin/bash","QT_ACCESSIBILITY":"1","GDMSESSION":"pantheon","LC_MEASUREMENT":"de_DE.UTF-8","GPG_AGENT_INFO":"/run/user/1000/gnupg/S.gpg-agent:0:1","LC_IDENTIFICATION":"de_DE.UTF-8","XDG_VTNR":"7","JAVA_HOME":"/usr/lib/jvm/java-8-openjdk-amd64/","PWD":"/home/joerg","ANDROID_HOME":"/home/joerg/Android/Sdk","XDG_DATA_DIRS":"/usr/share/gnome:/usr/share/pantheon:/home/joerg/.local/share/flatpak/exports/share:/var/lib/flatpak/exports/share:/usr/local/share:/usr/share:/var/lib/snapd/desktop","XDG_CONFIG_DIRS":"/etc/xdg/xdg-pantheon:/etc/xdg","LC_NUMERIC":"de_DE.UTF-8","LC_PAPER":"de_DE.UTF-8","QT_IM_MODULE":"ibus","XMODIFIERS":"@im=ibus","GNOME_DESKTOP_SESSION_ID":"this-is-deprecated","XDG_MENU_PREFIX":"gnome-","SESSION_MANAGER":"local/rog:@/tmp/.ICE-unix/4194,unix/rog:/tmp/.ICE-unix/4194","GIO_LAUNCHED_DESKTOP_FILE":"/usr/share/applications/code.desktop","GIO_LAUNCHED_DESKTOP_FILE_PID":"18035","CHROME_DESKTOP":"code-url-handler.desktop","ORIGINAL_XDG_CURRENT_DESKTOP":"Pantheon","VSCODE_NLS_CONFIG":"{"locale":"de","availableLanguages":{},"languagePackSupport":true}","VSCODE_NODE_CACHED_DATA_DIR":"/home/joerg/.config/Code/CachedData/91899dcef7b8110878ea59626991a18c8a6a1b3e","VSCODE_LOGS":"/home/joerg/.config/Code/logs/20200811T203240","VSCODE_IPC_HOOK":"/run/user/1000/vscode-f8c03cfe-1.47.3-main.sock","VSCODE_PID":"18035","LESSCLOSE":"/usr/bin/lesspipe %s %s","LESSOPEN":"| /usr/bin/lesspipe %s","LS_COLORS":"","NVM_BIN":"/home/joerg/.nvm/versions/node/v14.5.0/bin","NVM_CD_FLAGS":"","NVM_DIR":"/home/joerg/.nvm","NVM_INC":"/home/joerg/.nvm/versions/node/v14.5.0/include/node","":"/usr/share/code/code","AMD_ENTRYPOINT":"vs/workbench/services/extensions/node/extensionHostProcess","PIPE_LOGGING":"true","VERBOSE_LOGGING":"true","VSCODE_IPC_HOOK_EXTHOST":"/tmp/vscode-ipc-2f14383e-97a0-478e-a0ab-c5f67fc4c6ec.sock","VSCODE_HANDLES_UNCAUGHT_ERRORS":"true","VSCODE_LOG_STACK":"false","APPLICATION_INSIGHTS_NO_DIAGNOSTIC_CHANNEL":"true","PATH":"/home/joerg/bin:/home/joerg/.local/bin:/home/joerg/.nvm/versions/node/v14.5.0/bin:/home/joerg/bin:/home/joerg/.local/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/usr/local/games:/snap/bin:/home/joerg/Android/Sdk/emulator:/home/joerg/Android/Sdk/tools:/home/joerg/Android/Sdk/tools/bin:/home/joerg/Android/Sdk/platform-tools:/home/joerg/flutter/bin:/home/joerg/Android/Sdk/emulator:/home/joerg/Android/Sdk/tools:/home/joerg/Android/Sdk/tools/bin:/home/joerg/Android/Sdk/platform-tools:/home/joerg/flutter/bin","PYTHONIOENCODING":"UTF-8","PYTHONUNBUFFERED":"1"},"stopOnEntry":false,"showReturnValue":true,"debugOptions":["ShowReturnValue","RedirectOutput"],"justMyCode":true,"workspaceFolder":"/home/joerg/iubh_alexa/IUBH","redirectOutput":true}]
[debug - 2020-08-11 18:53:26.326Z] Successfully uploaded telemetry data.

Expected behavior

Being able to test the skill locally.

Desktop (please complete the following information):

OS: Linux x64 4.15.0-101-generic
Visual Studio Code Version: 1.47.3
Alexa Skills Toolkit Version: 2.0.0
Git Version: git version 2.17.1

@joerg86 joerg86 added the bug Something isn't working label Aug 11, 2020
@nikhilym
Copy link
Contributor

Hey @joerg86 , thanks for reporting this issue. Looks like virtualenv has problems figuring out site packages in Linux environments, since the same code works fine in virtual envs in Mac/Windows. Anyways, as mentioned in the underlying issue that you tagged, we definitely need a better way to check if the local debug package is installed in the python interpreter selected.

Since this is related to virtualenv issues, to get unblocked, can you install the ask-sdk-local-debug package to the global site-packages location and change the interpreter to use that instead?

@nikhilym nikhilym added the response needed use this if you need more information regarding the issue label Aug 11, 2020
@joerg86
Copy link
Author

joerg86 commented Aug 11, 2020

Hi @nikhilym , thanks for the super fast response. Yes, installing ask-sdk-local-debug and switching to the global interpreter fixes the issue. However, this would then force me to install all my skill's python requirements globally which is really problematic (version conflicts etc.).

Anyway, good news: I have solved the problem.
It seems like the virtualenv (from python3-virtualenv deb package) shipped with Ubuntu 18.04 is outdated and the problem is solved in newer versions. After doing a sudo pip install --upgrade virtualenv followed by deleting and rebuilding my virtualenv everything works fine (virtualenv version 20.0.30).

Sorry for bothering you with that! Anyway, we now have a documented solution - just in case anybody else runs into this problem.

Thanks,
Jörg

@nikhilym
Copy link
Contributor

Oh wow, thanks for the update @joerg86 . This should definitely be added in your FAQs then. I was about to do more research on this, but glad that you figured this out.

Closing this ticket at the moment. Please let us know if you face any problems with the extension or your general feedback about it 😄

@nikhilym nikhilym removed the response needed use this if you need more information regarding the issue label Aug 11, 2020
tydonelson pushed a commit that referenced this issue Mar 18, 2023
- Update Alexa hosted skills deployment page
- Add git operations listener & refactor skill deploy view logic & add export skill package command
- Rebase & add error messages when skill deploy failed
- Improve deploy skill page rendering & change createZipFile input parameter
- Fix bug bash issues:
    Improve deploy skill page rendering (bug #15) &
    Non-hosted skill dynamic skill package path issue (bug #18, #25, #29) &
    Update force deploy indication (bug #22, #24) &
    Add lambda code indication in non-hosted skill deploy page (bug # 26, #27)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants