VS Code Python Extension Failed to Activate - python

The Python extension is failing to load for me. I noticed it was updated earlier this morning and I haven't changed my VS Code configuration or added any new extensions. Any suggestions?
Here is the output of the extension:
[ERROR 2023-1-6 11:16:39.302]: extension activation failed [TypeError: Expected a string, got undefined
at e.exports (c:\Users\tmorg\.vscode\extensions\ms-python.python-2023.2.0\out\client\extension.js:2:1980955)
at b (c:\Users\tmorg\.vscode\extensions\ms-python.python-2023.2.0\out\client\extension.js:2:138478)
at y.update (c:\Users\tmorg\.vscode\extensions\ms-python.python-2023.2.0\out\client\extension.js:2:133796)
at y.initialize (c:\Users\tmorg\.vscode\extensions\ms-python.python-2023.2.0\out\client\extension.js:2:137868)
at new y (c:\Users\tmorg\.vscode\extensions\ms-python.python-2023.2.0\out\client\extension.js:2:128788)
at y.getInstance (c:\Users\tmorg\.vscode\extensions\ms-python.python-2023.2.0\out\client\extension.js:2:129446)
at h.getSettings (c:\Users\tmorg\.vscode\extensions\ms-python.python-2023.2.0\out\client\extension.js:2:140722)
at c:\Users\tmorg\.vscode\extensions\ms-python.python-2023.2.0\out\client\extension.js:2:409217
at async t.activateComponents (c:\Users\tmorg\.vscode\extensions\ms-python.python-2023.2.0\out\client\extension.js:2:408578)
at async c:\Users\tmorg\.vscode\extensions\ms-python.python-2023.2.0\out\client\extension.js:2:3124940
at async e (c:\Users\tmorg\.vscode\extensions\ms-python.python-2023.2.0\out\client\extension.js:2:3124490)
at async f.n (c:\Users\tmorg\AppData\Local\Programs\Microsoft VS Code\resources\app\out\vs\workbench\api\node\extensionHostProcess.js:94:6818)
at async f.m (c:\Users\tmorg\AppData\Local\Programs\Microsoft VS Code\resources\app\out\vs\workbench\api\node\extensionHostProcess.js:94:6781)
at async f.l (c:\Users\tmorg\AppData\Local\Programs\Microsoft VS Code\resources\app\out\vs\workbench\api\node\extensionHostProcess.js:94:6238)]

You could roll back to the historical version in the extension store to solve this problem.
If you want, you can also follow this issue on github, it's the same problem.

I had the same issue (at least it seemed the same), however it is possible to work around it if you are using the Python extension in conjunction with Remote Debugging.
You can ignore the extension's activation failure if that is your primary use, since VSCode is still able to debug remotely using Python Remote Attach.
After some more work on this, I found that updating the Python Extension to the pre-release version cleared up the various errors that came with the recent updates.

Related

Ride.py shows Calling method 'start_keyword' of listener XXX failed

I'm trying to run an automated test in Ride.py. This test works on my colleague's computer but for some reason does not work on mine. The test starts but at a certain point i get the following error:
[ ERROR ] Calling method 'start_keyword' of listener 'C:\Python27\lib\site-packages\robotide\contrib\testrunner\TestRunnerAgent.py' failed: IndexError: list index out of range
The interesting part is that this error occurs on the same spot ever time, but with a different test it happens at a different time.
I tried to google several things and nothing worked. One solution suggested there was a '#' commented somewhere and this caused the crash. I looked but I don't see a '#' commented anywhere.
Another suggestion lead me to believe my testrunneragent.py file must have been installed wrong. I went online to find the file and replaced it. This did not work either (reran the test before and after a restart of ride)
We tried to re-import the test files thinking perhaps something went wrong there. This did not help either.
Googling juts the last part (IndexError: list index out of range) gave me the suggestion it does not recognize all the lines of code in the back-end file. I would have no clue how to solve this as im not a major coder.
One difference between me and my colleague could be the versions. I downloaded python version 2.7.16 and ride 1.7.3.1. My colleague uses an older version of both python and RIDE. Perhaps the problem could be here?
https://paste.fedoraproject.org/paste/TLekH3az0m4wuUyM8C2RYw
I expect the test will run without failing (it is a happy flow) I have included some screenshots with code in the previous segment that might help
downgraded to the same version of Ride.py
This seems to have fixed the issue

Micropython 1.9.3 - How to compile .py #micropython.native code into .mpy?

I'm on Micropython 1.9.3. I know how to use mpy-cross to turn a .py into a compiled python .mpy that can be executed by the Micropython virtual machine.
The problem is that if I try to compile using #micropython.native i.e. compile the Python script to native code instead of bytecode, I get an error:
../../mpy-cross/mpy-cross -o build/frozen_mpy/./frozentest.mpy -s frozentest.py frozentest.py
ValueError: can only save bytecode
On the following .py
#micropython.native
def native_add(a,b):
return (a+b)
c = native_add(2342,4542)
QUESTION
Is it not possible to embed native code in .mpy format? Did I miss some option in mpy-cross/mpconfigport.h?
Only thing I changed is:
#define MICROPY_EMIT_THUMB (0) // changed it to 1
I got the answer from someone on micropython forum:
You cannot. It is an TODO item. If you want to put it into flash
memory, you can embed it as frozen source code in some ports. Just put
these files in a subdirectory called scripts, like esp8266/scripts or
stm32/scripts. But it will still be compiled at import time and
consume RAM. Typically, that should not hurt, when this variant of
coding is used only for small, time-critical sections of the code.

ITK in Python: SimpleITK or not?

I have started to work with ITK for a week thanks to SimpleITK in Python. Even though, currently, I am satisfied with SimpleITK, I have noticed that some features such as the Powell optimization scheme or the OnePlusEvolutionary one are not available in SimpleITK. It seems to be the same with landmark-based registration methods.
So, I was wondering if there is a way to retrieve all the features available in ITK (in C++) in SimpleITK or if it is necessary to perform my own wrapping?
If not I will later learn C++ to do so!
Thanks!
You are correct. SimpleITK is limited in functionality. It is however possible to access the entire ITK library in Python using the WrapITK interface. This is an old interface which I don't believe has been updated for a while. However, it is still possible to compile new builds from source and use WrapITK.
The process is not exactly smooth. I have done the build on a Windows machine in the past and had then noted some of the not-so-smooth-steps that I had to encounter. I'll lay those down here. Since you haven't mentioned your OS, I'm going to go ahead explain the setup for Windows. Let's see if you're able to get it up and running.
ITK-4.6 + Python2.7 + CMake + VS2008 professional (all 32-bit)
Nothing later than VS2008 can compile GCCXML, which is required for generating python bindings
After configuring CMAKE, the following flags need to be additionally set:
ITK_WRAP_PYTHON
ITK_WRAP_* (all types: float, double, etc.)
ITK_BUILD_SHARED_LIBS (gets automatically set if first flag is set)
In VS2008, build in Release mode only. Number of projects in the project explorer will be more than 500. Around 300-350 should get built.
When building, make sure that you have an accessible internet conection for downloading GCCXML (which will likely get downloaded after you have started the build in VS2008). There should be no error while verifying the download. If there is, it might be because of directory creation permission errors.
The project should get built with NO ERRORS
Copy the WrapITK.pth file from the ITK build/Wrapping/Generators/Python/Release to Python/Lib/site-packages
Add the following to your Path variable:
C:\ProgramLibs\ITK\build2008\lib\Release
C:\ProgramLibs\ITK\build2008\bin\Release
C:\ProgramLibs\ITK\build2008\lib
Now ITK should work properly (below is a test python file that you can use to run a sanity check on the build). Except every time you call itk.Image the first time in your program or on the Python interpreter, there are a dozen warnings and they take time to execute that. This is a known issue. Once you are past this, it's smooth.
Test file
import itk
pixelType = itk.UC
imageType = itk.Image[pixelType, 2]
readerType = itk.ImageFileReader[imageType]
writerType = itk.ImageFileWriter[imageType]
reader = readerType.New()
writer = writerType.New()
reader.SetFileName("<input image file location>")
writer.SetFileName("D:/Output.png")
writer.SetInput( reader.GetOutput() )
writer.Update()
There is also WrapITK, which is a python wrapping of ITK that you can enable to compile with ITK (so, you'll have to compile it by yourself but you will not need to code the warpping at least). See http://kitware.com/blog/home/post/888, http://www.itk.org/Wiki/ITK/Wrapping , http://www.itk.org/Wiki/ITK/Release_4/Wrapping/WrapITK_Installation.t .
Note however that probably not all filters are wrapped (http://www.itk.org/Wiki/Proposals:Increasing_WrapITK_Coverage#List_of_Unwrapped_Filters , last updated in 2009 so probably now the situation is better).
The only compiled wrapITK package I came across is Devide-RE https://www.youtube.com/watch?v=-b1zS536R2M (with an older version of ITK, 3.2 if I remember correctly), but maybe also Slicer and Vistrail have it (http://www.itk.org/pipermail/insight-users/2009-August/031910.html)

py2neo - neo4j.GraphDatabaseService(db_string) crashes python; no error-log

the last couple of days I installed Python 2.7.3 and Neo4J community edition 1.8.M01. I managed to get the embedded python bindings to work, but as I need the py2neo REST bindings I've installed them like described at http://py2neo.org/. Moreover I can't download directly from git due to a "Permission denied (publickey)" error so I took the available py2neo-1.2.6.tar.gz version from the download section.
While the installation itself was not the problem, I can't get the example to work as on calling neo4j.GraphDatabaseService('http://localhost:7474/db/data') python crashes without any error message - Win7 64bit only pops up a message that the applicationn does not respond. Java, Python and Neo4J are all running on 64 bit basis and the server is accessible on http://localhost:7474. I even tried to force an output as described here: Catching a python app before it exits - but still no stacktrace or error-log.
I've installed everything from scratch or via the executables provided at www.lfd.uci.edu/~gohlke/pythonlibs/ several times now but nothing managed to get this example to work.
I have installed both tornado 2.2.1 and pycurl 7.23.1. pycurl.version_info() reveals: (3, '7.23.1', 464641, 'Windows', 28, 'OpenSSL/0.9.8s', 0, '1.2.5', ('gopher', 'http', 'https', 'imap', 'imaps', 'pop3', 'pop3s', 'rtsp', 'smtp', 'smtps'), None, 0, None) - moreover
c = pycurl.Curl()
c.setopt(c.URL, 'http://stackoverflow.com')
c.perform()
returns the content of the startpage.
I've followed the stacktrace via print-messages into tornado.IOLoop.start() and there into _run_callback() where it actually executes callback() and crashes. Not shure if the callback-function defined inside of tornado.HTTPClient.fetch() should be called here - printing the callback results in <tornado.stack_context._StackContextWrapper object at ...>
Any suggestion on how to fix this issue?
Thanks in advance,
Roman
edit: corrected port as of a typo
edit2: after a longer debug-session which narrowed the point of failure a bit, Nigel provided me with a way to deal with my issues by exchanging
self._http = http or httpclient.HTTPClient(curl_httpclient.CurlAsyncHTTPClient)
with
self._http = http or httpclient.HTTPClient()
in line 55 of rest.py. This is a workaround but does not solve the problem in the back of tornado/pycurl. The windows management console declares pycurl.pyd as the reason for the crash and as some of the nodes (after a seldom functioning intialization of the GraphDatabaseService) get stored within Neo4J and the Debug-Output below isn't shown anymore, the crash must occur between the send request and the return to the main application. I currently believe that either the Selection poll, which I fall back on Windows, is the reason for the crash or maybe the curl-handle gets shared between different threads - which should not happen (http://curl.haxx.se/libcurl/c/libcurl-tutorial.html) - and is somehow the most comprehensible reason imo
Sorry to hear that you're having issues with py2neo. I haven't carried out any testing under Windows since I only run Linux so I'm unsure whether there are any general incompatibilities there. I am also aware that error reporting is less than it should be which has been limited by the amount of time I've had to work on the project.
That said, I notice that you are running on port 4747 instead of the default 7474 - or this this a typo? Have you tried your short cURL test against the root database URI directly?
You seem to have covered all the bases looking at the layers involved so I'm unsure what else to look at here. I have considered adding an option to be able to switch between the curl_httpclient and the simple_httpclient - this may give an alternative to try. I will try to get something put up over the next few days.
Nige

Eclipse+PyDev+GAE memcache "Undefined variable from import: get"

I've started using Eclipe+PyDev as an environment for developing my first app for Google App Engine. Eclipse is configured according to this tutorial.
Everything was working until I start to use memcache. PyDev reports the errors and I don't know how to fix it:
Error: Undefined variable from import: get
How to fix this?
Sure, it is only PyDev checker problem. Code is correct and run on GAE.
UPDATE:
I'm using PyDev 1.5.0 but experienced the same with 1.4.8.
My PYTHONPATH includes (set in Project Properties/PyDev - PYTHONPATH):
C:\Program Files\Google\google_appengine
C:\Program Files\Google\google_appengine\lib\django
C:\Program Files\Google\google_appengine\lib\webob
C:\Program Files\Google\google_appengine\lib\yaml\lib
UPDATE 2:
I took a look at C:\Program Files\Google\google_appengine\google\appengine\api\memcache\__init__.py and found get() is not declared as memcache module function. They use the following trick to do that (I didn't hear about such possibility):
_CLIENT = None
def setup_client(client_obj):
"""Sets the Client object instance to use for all module-level methods.
Use this method if you want to have customer persistent_id() or
persistent_load() functions associated with your client.
Args:
client_obj: Instance of the memcache.Client object.
"""
global _CLIENT
var_dict = globals()
_CLIENT = client_obj
var_dict['set_servers'] = _CLIENT.set_servers
var_dict['disconnect_all'] = _CLIENT.disconnect_all
var_dict['forget_dead_hosts'] = _CLIENT.forget_dead_hosts
var_dict['debuglog'] = _CLIENT.debuglog
var_dict['get'] = _CLIENT.get
var_dict['get_multi'] = _CLIENT.get_multi
var_dict['set'] = _CLIENT.set
var_dict['set_multi'] = _CLIENT.set_multi
var_dict['add'] = _CLIENT.add
var_dict['add_multi'] = _CLIENT.add_multi
var_dict['replace'] = _CLIENT.replace
var_dict['replace_multi'] = _CLIENT.replace_multi
var_dict['delete'] = _CLIENT.delete
var_dict['delete_multi'] = _CLIENT.delete_multi
var_dict['incr'] = _CLIENT.incr
var_dict['decr'] = _CLIENT.decr
var_dict['flush_all'] = _CLIENT.flush_all
var_dict['get_stats'] = _CLIENT.get_stats
setup_client(Client())
Hmm... Any idea how to force PyDev to recognize that?
There is a cleaner solution: Try adding GAE's memcache to your forced builtins.
In your PyDev->Interpreter-Python->ForcedBuiltins window, add the "google.appengine.api.memcache" entry and apply.
Double-click on the memcache errors to check them back, they disappear!
Please make sure that system pythonpath includes google APE install directory.
I'm a bit late to the party, but you can add the following comment in all of your files that use memcache to selectively switch off pydev analysis:
##PydevCodeAnalysisIgnore
If you don't want to turn off all code analysis for your project/module, then just turn it off for that line. This answer explains that you can hit Ctrl+1 to bring up quick fix and insert ##UndefinedVariable at the end of the line.
What version of PyDev are you using? A recent one (1.5) or the old one referred by the Google tutorial?
See this thread.
There is a similar issue with PyROOT
Since PyDEV plugin does not read $HOME/.pystartup, touching functions/ classes is not a solution. Because it analyze the syntax and structures of python modules to be imported not on-the-fly but when I set the PYTHONPATH from Eclipse's preference panel.
So does your PYTHONPATH reference the Google library?
They might be an issue with code completion in 1.5 which could force you to disable code analysis: Pydev 1.5.0 code anlaysis breaks code pyqt4 code completion - ID: 2855598
have pyqt 4.5.4 installed.
Initially I had pydev 1.4.8 the open source version installed and code completion worked fine.
After updating to pydev 1.5.0, pyqt code completion stopped functioning.
After disabling the Pydev code analysis in "eclipse preferences -> pydev -> editor -> code analysis -> do code analysis?", code completion began working again for PyQt
classes etc.
This worked for me and it's different than the solutions above.
Pretty straight forward:
http://blog.kicaj.com/fixing-pydev-memcache-unresolved-import/
Just says to add the google_appengine folder to the pydev python interpreter library.
I fixed that by adding this few lines to my code on the top of my file:
from google.appengine.api import memcache
# work-around for Eclipse+PyDev+GAE memcache error
if not hasattr(memcache, 'set'):
Client=None
memcache.setup_client(Client)
memcache = Client
You can commnet it out in production version.
It's only to keep eclipse happy and to let code completion work.

Categories

Resources