I've gone through the steps to get started with Lego EV3 and python described here: https://education.lego.com/en-us/support/mindstorms-ev3/python-for-ev3 however visual studio code isn't giving me any intellisense into pybricks.
In order to get anything up and running I'm having to constantly reference the pdf documentation. While that isn't an issue for me personally (2 monitors), it will be come this September when I'm trying to teach a class of 4-6 grade kids how to code on small laptops.
The root of the issue is that deploying the application involves copying all the files onto the robot where pybricks is present and all the imports actually work. However locally in VSCode none of the imports work properly so there's no autocomplete magic.
Anyone know the best solution for getting autocomplete/intellisense up and working?
You have to install python-ev3dev2 package.
You can check the description at the end of this page:
https://github.com/ev3dev/vscode-hello-python
You will either need the source code or you could write .pyi files -- which are basically just typed stub files -- to provide the typing information.
As of 2019, simply installing pybrick stubs did the job for me:
$ pip install pybrick-stubs
Related
What I get when I try to run it
Nothing I'm trying to import is being recognized by the IDE. I do have to admit, I am a fairly novice programmer, and the process of successfully importing external modules (, the ones that don't come with python,) is very confusing to me right now. But from everything I could scrap online, it seems like for VS 2022 I first have to go to [TOOLS] > [PYTHON] > [PYTHON ENVIRONMENTS]. Then from the environments popout I select my python version (, which is 3.10 (64-bit),) update my pip if not already up to date, search for my desired package and download. The terminal said the download completed but the IDE still can't find the import.
My installed packages in my python environment
This is a problem I've been putting off for months, and in the past I downloaded the packages through the Windows command prompt instead of the IDE. I'm not sure if it's any different, I'm not sure if one is more right. The result was the same regardless, it didn't work. And after several uninstalls and reinstalls, I even tried moving the entire package folder into my project folder to see if anything would change. The import was accepted but something in the packaged errored out. Moving files like that doesn't seem like the correct way anyway, I just want to make sure I bring up everything I tried to fix this.
I suspect that solution is something super simple that I'm just overlooking or don't know. I still kind of think the package needs to be with my .py file in some way but I'm unsure. If you can save me I'd appreciate it because I've been stumped for a while now.
I know my code is super simple, but I just wanted to show the error. I get the error before it prints.
I'm working on an (Windows and Mac) application that uses Python as an embedded scripting language.
The application includes an internal text editor, implemented using Scintilla, and I'm using Jedi for autocompletion, which generally works great.
However, when attempting autocompletion on a computer that does not have a separate installation of Python, Jedi raises an error:
jedi.api.environment.InvalidPythonEnvironment:
Could not get version information for 'python':
FileNotFoundError(2, 'The system cannot find the file specified', None, 2, None)
Digging into the code, I can see that the underlying code that is throwing the FileNotFoundError is when Jedi attempts to run python using subprocess.Popen. Python is not installed on the computer, so this fails.
I can also reproduce the same issue on a computer that does have Python installed by editing my Path environment variable not to include the location of python.exe.
Ideally, we don't want users of our application to have to install Python just to get autocompletion working.
My questions:
Is it possible to get Jedi not to spawn subprocesses, and instead run its code inside the same instance of Python within which it itself is running? I couldn't find anything about this in the documentation or the source code that deals with Environments, and extrapolating from the discussion here I suspect the answer might be no.
Is it possible somehow to get Jedi to use the same python37.dll that our application is using for its functionality, instead of looking for a .exe file that does not exist?
Is there any way we could make some kind of minimal Python installation within our existing app installation that uses the same DLLs/Python Lib etc? How could I go about doing this?
Is there any other way to get Jedi autocompletion working in our app without requiring the user to install Python, or including a full Python installer as part of our build process?
Is it possible to get Jedi not to spawn subprocesses, and instead run its code inside the same instance of Python within which it itself is running? I couldn't find anything about this in the documentation or the source code that deals with Environments, and extrapolating from the discussion here I suspect the answer might be no.
This is definitely possible. All the tools are there. There are discussions ongoing here: https://github.com/davidhalter/jedi-vim/issues/870.
IMO a patch to Jedi is needed that uses an jedi.api.environment.InterpreterEnvironment in some cases like yours. It's definitely possible, it's just buggy at the moment.
I am trying to debug an application that is written in Python 2. Problem is, before application can be run, it must be installed (according to the documentation) like this:
python setup.py develop
Application (Cuckoo Sandbox) then can be run like this:
cuckoo -d
With the new Python package developing and testing code now works slightly different than it used to be. As one
will first have to Install Cuckoo before being able to use it in the first place, a simple modify-and-test development
sequence doesn’t work out-of-the-box as it used to do.
Is it possible to somehow debug such application?
Later in the (unfinished) docs there is a mention of debugging web interface which I am not sure would get me to the code I need to debug and it also requires PyCharm Professional. I am using PyCharm Community but I am willing to use any other free IDE or debugger.
It will be difficult to debug if you are working only with compiled .pyo and .pyc files, which is all that you might have from an installed application. It is possible that the install includes some source files. You will have to figure out where it is installed, which is platform specific. Since many projects (including cuckoo) are open source, I would recommend cloning the Github repository and debugging from that.
I just installed the Python development workload for VS 2017 but the editor shows none of the red squiggly underlining for syntax errors that I'm used to seeing with C# on VS, nor any entries in the error list. If I try to run the code with errors, it warns me there are errors in the code but does not specify what they until exceptions are thrown from running.
I've tried reinstalling the workload and looked through every available option under the Tools/Options tab but can find nothing about syntax errors. Any fixes detailed for earlier versions of VS no longer seem to apply, what am I missing?
I had exactly the same problem using the simplest project from the VS Python tutorial.
The fix was to upgrade from VS 15.4.1 to 15.5.
Walt
I have had the same thing happen to me. Though this was actually with a C# application. I noticed Visual Studios stopped detecting the errors after adding a few NuGet references and doing some manual modifications of the project files. I noticed that this was only happening on this one project. All the other projects I worked on did not seem to have the same issue.
I was able to get it to start working again by creating a new project, moving my code over, and adding the references back one by one. For this situation, it looked as if a corrupt project file or bad reference was to blame even though the project would compile and run correctly.
Does this issue exist in other programming languages/projects?
At work we are using Trac on several internal wiki's and an external wiki. REcently we found the need for a new plugin. After we going through a few tutorials we went to install a plugin to make sure it would work. It didn't. We've been going through trying to figure out. Below I will list the steps and various things I did while trying to get it to work.
1) I went to trac-hacks website and downloaded their hellow world plugin, figured I couldn't make a mistake using their code.
2) I compiled and made an egg using python setup.py bdist_egg on the machine where trac is installed, to make sure it's the same Python version being used.
3) I then copied it over to /directory/where/trac/is/plugins/ folder and chmod 755 the file egg file.
4) I then restarted http, unable to find a better way of restaring trac so this may be where my problem is. It didn't work. So I deleted the egg folder in plugins
5) Uploaded it via trac->administration->plugins and restarted httpd again. Nothing.
6) I realized I had to edit the trac.ini file and added helloworld.* = enabled under component and restarted the web server.
It's quite possible it's me but any help would be greatly appreciated!
Its the helloworld plugin from trachack, essentially displays hello world and theres a button. There are no error messages provided, hence why googling was hard.
I'm assuming that it's using root and that's the user I built it with. I will look into seeing if it's anybody else, just taking a quick look though I don't see anything else that could be using it. I only copied the egg file to the plugins folder, I set up another folder elsewhere and built it and cp to the plugins folder. I'm glad to know I was doing that right because looking up documentation on how to restart trac turns up practically nothing, they just say restart trac or restart apache. I will look into the logs later on tomorrow. Thanks for the replies! Also we are using trac .12.1.
So after looking at the log files it seems that it doesn't even load the plugin, can't find anywhere that says it's loading or any errors with it. Now we have a few trac sites for various projects and one of the sites already has plugins installed so I went there and and put the test plugin there and checked logs and it didn't work either. So I'm just going to conclude it's the plugin or something we already have in place and it's not me. I believe I'm going to try and make one and test it. Thanks for the help!
It sounds like you built the egg correctly. After you copy it into your plugins folder, change the file's owner and group (I'm assuming you're on Linux since you mentioned chmod) to match the account that your webserver uses. I'm not sure if that's strictly necessary, but it's what's always worked for me.
I may be misreading your #4, but it sounds like you copied the whole egg folder to your plugins directory. Only the .egg file needs to be copied over, it's a self-contained package. I don't think Trac looks for .egg files in subdirectories.
Restarting your webserver is the easiest way to restart Trac. Actually, I'm not aware of any other way to do it.
When it comes to plugin problems, Trac's log is usually a very good source of information. I recommend setting Trac's log level to DEBUG, then shut down the web server. Clear out the contents of Trac's log file, then start the web server and make a copy of Trac's log file after the server has completely come back online. Do this process twice: once with the plugin installed and once without it installed. The difference in the logfiles should give you a good indication of what the problem is. Once you get accustomed to what your logs normally look like, you'll be able to read the log in place without clearing it out and generating two versions of it.
By the way, what Trac version are you using?
Check the Trac version and downloaded plugin
instead python setup.py bdist_egg try python setup.py install
Quite an old thread, but since I ran into the same problem at one point:
Make sure you build the .egg with the same Python version that you use to run Trac with!Backwards compatibility between Python versions does not matter here, because Trac reads information about the Python version out of the .egg file before it even loads it, to make sure it is compatible.
(Small version numbers should not matter, so you should be able to run a .egg with Python 2.7.10 when it was built with 2.7.3, but not when it was built with 2.6.x. Look at the Version number that is written into the .egg file name.)