PyDev does not highlight and autocomplete Numpy correctly - python

I am using a mac, I set up all the external libraries through PYTHONPATH, I tried setting it through Pydev interpreter as well.
It simply does not work. The odd thing is that pydev is highlighting the syntax as error, but when I run the code, it works perfectly. I am out of ideas of what the problem might be. I used to program in java with eclipse, and once you set up the external libraries all the highlighting and autocompletion is working. With pydev I have no idea what is wrong.
Here is the image of the wrong highlighting:

There's a similar problem with importing wxPython with PyDev Aptana Studio 3. Based on the research I did then, PyDev has a hard time validating new imports when a module has recently been downloaded. This means that there is just a bug in PyDev, so it would be a good idea to report it.
As for the solution, from what I've found a useful link with a ton of answers that should fix your problem. There's some detailed instructions but the fix that I found was towards the bottom someone said to try wx = wx after importing wx. This worked for me, but may not work for you so here is the link if you need a better answer:
Undefined variable from import when using wxPython in pydev

Related

Why is VS Code showing "windll Windows only: Creates ()" intellisense suggestions?

While writing Python code on VS Code, it is showing suggestions like:
windll Windows only: Creates ()
I have tried to see if this was coming from snippet extension I might have installed but I don't think I have any... can anyone shine a light on why I am getting his code completion nonsense?
I had this same issue, every time :, ., def, or if is typed, there's annoying suggestions that don't make sense. I found out it's the Python Extended extension that's responsible for this. It seems to be reported on it's GitHub issues page, but for now I would disable the extension as it doesn't seem to be working at all for me. I recommend PyLance as a replacement.
It's the extension problem.
You have installed the extension named: Python Extended inside your vs code and you will need to uninstall it.
It works well on my editor after uninstalling this extension.

Why aren't my imports for Python working in VSCode?

First of all, I am new to both Python as well as the world of VSCode (recently moved over from Atom). I will also say that I am using an Early 2014 MacBook Air running macOS Catalina. I really do love VSCode! It's amazing in many ways, but this... this is just too unclear.
Okay, I have tried literally almost everything and I don't understand why my imports won't work! I have looked at the documentation on the issue on Github (I will say I may have something with the directory wrong there, referring to the docs). I have tried the "python.autoComplete.extraPaths": [], thing. I have tried changing my (virtual) environment and, of course, setting up a new one myself. I have tried setting "python.languageServer:" to Jedi and back to Microsoft. I can't even find the "python.jediEnabled: false" comment that everybody is telling me to uncomment.
Yet, my imports are still "unresolved (Microsoft language server)" or "not found (Terminal)" or "unable to be imported (Pylint)". It just makes me so angry and I don't understand what I've done wrong!
I've seen modules like pygame and requests work just fine on VSCode for many others (YouTube), yet mine has yet to work.
Can someone please tell me the secret that I don't apparently know? Thanks.
Update Post: My Virtual Environment is using my System Python rather than my Venv's Python
Thank you for everyone who has helped (so far). I am getting a lot closer to solving this. ^-^
They had removed "python.jediEnabled" setting instead of "python.languageServer", you can refer to here.
Maybe you haven't installed the package which you want to import, because you had used the wrong 'pip'. When you select the right environment, you need to activate it(Ctrl+Shift+`), otherwise, you'd use the wrong 'pip'. You can type 'pip --version' to check which 'pip' you are using. Then you can try to install the package you want to import.

Autocompletion in PyCharm not working. I've made sure the intepreter is pointed to my project and I've tried invalidating caches

I remember autocompletion to be working for me on PyCharm some time ago, but I just noticed that is no longer is. It doesn't work for basic python syntax as well as any libraries.
I've tried using the "Invalidate Caches and Restart" option in the File menu of PyCharm. I've also made sure that the Project Interpreter is using the Python in the venv of the project created by PyCharm. I've tried a handful of other things but these two are the most common solutions I've encountered and nothing is working. Note that hitting Ctr-Space anywhere just gives me a "No suggestions" message (not sure if this is relevant but thought I'd mention it).
Any ideas? Any help or ideas at all are appreciated.

Eclipse PyDev now shows all references to Tkinter as errors

I've been using Eclipse with PyDev (on Windows, mind you) for my Python Tkinter project for about a month now, and up until recently I've had no complaints. I start the source for one module (my GUI) like so:
from Tkinter import *
Now, ever since I updated Eclipse to 3.6.1, it shows an error for every call to the Tkinter module(Frame(), Label(), Tk(), etc.). I thought that something might have gone wrong during the update, so I uninstalled Eclipse, re-downloaded it (Eclipse 3.6.1 Classic), and reinstalled it. Then, seeing that that gave me a bunch of errors with installing PyDev, I removed that, got Eclipse 3.6.0 Classic, installed it, and got the same problem I was trying to fix earlier.
I don't understand what's wrong here. It doesn't make any sense to me why all of a sudden Eclipse would stop recognizing that I had imported Tkinter.
Can anyone offer any suggestions/input? I really want to stick with Eclipse, I'm very happy with it, but I can't deal with it giving me about 200 bogus errors.
You really shouldn't use wild imports. Consider from Tkinter import Frame, Label or import Tkinter as tk instead.
Now to your problem: I have Eclipse Helios, too (3.6.0.v20100602). The problem you describe clearly has to do with PyDev, not with the Eclipse base project. I just tried the same import and didn't get error messages. My PyDev version also retrieves the docstring of Frame correctly, for example.
I think it boils to just installing a newer version of PyDev (this is the solution for many bugs ^^) - add "http://pydev.org/nightly" as an update site and then upgrade to the latest version. I have version 1.6.3.20100922, by the way. If that doesn't help, you should consider reporting it as a bug.
I find the answer to problems like this is usually that you have to update your pythonpath from eclipse. See my answer to a similar question. I think re-installing pydev and/or eclipse usually solves this problem because in doing so, the pythonpath is re-configured.
Which Python version do You use? If > 3.1 try (note lowercase writing):
from tkinter import *

PyDev bugs with imports

I am using PyDev/Eclipse for several monthes and I get ever and ever the same bugs with imports:
PyDev underline in red an import and say Unresolved import xxx ; Found at yyy. When I click on yyy eclispe find and open the implementation of the module.
(PyDev just inform me that it can't find the module xxx and in the same message that it can find it !)
The module xxx is in the PYTHONPATH of eclipse. When I "explore" the interpreter of the project, I can find it without any problems.
When I try to execute (from eclipse), I don't get any error and it works fine.
Sometimes, the error message will stay for several days and will disappear. Sometimes, it won't. I've tried to refresh the projects but it has not impact on that.
Somtimes, it works well on a project and I can use autocompletion and it don't work in another project (same interpreter) ...
I just can't understand what is happenning ?
So far, I have ignored these bugs because everything was fully fonctionnal but sometimes, it is a bit disturbing to have red markers "errors" when you are working.
Did you find a way to avoid these bugs in PyDev ? Is it "normal" ? Is there a way to force PyDev to "refresh" ?
Thank you.
References :
python 2.4.4 (built from sources)
PyDev v 1.6.0 2010071813
This can happen if new modules are not cached by PyDev. For example, on my new laptop I first set up PyDev/Eclipse and later installed the Django package. That's why Django imports were marked as unresolved. You can refresh it using Pydev > Interpreter - Python > Libraries > Apply. Select the interpreter you want to "restore" (they could have chosen a better word) and click OK. PyDev will then reparse all installed modules.
I'm using the nightly version of PyDev, but any 1.6.x version should work correctly. If that doesn't help, remove the interpreter configure and create a new one.
You can try refreshing your PYTHONPATH in Preferences > Pydev > Interpreter - Python and selecting AutoConfig for your interpreter, then manually choosing the libraries for your PYTHONPATH.
This is pretty radical solution though. Making an insignificant change (like adding a space) and saving file should work in most cases. If not, you can also try temporary delete and then re-add the imports in file that is causing problems.
Just in case anyone else runs into this thread but above answers don't solve the issue, make sure that your script does not have the same name as the library that you are trying to import.

Categories