I'm working on a Django project and this error keeps coming up on the first line of every file I work on. I recently reset my computer and this is my first time using VSCode after.
Please, what should I do?
I changed my Linting settings on VSCode. I opened the Command Palette (Ctrl+Shift+P) and selected the Python: Select Linter command. I clicked on Pylint. I had multiple linters enabled before but this replaced them all with Pylint and it worked.
I also followed the steps below.
Pylint-django raising error about Django not being configured when that's not the case (VSCode)
Related
While beginning to teach a friend how to code in Python, I observed something in his VSCode that was different than my own - he could mouse-hover on a Python keyword such as as import or def, and it would show the Python Manual definition for the keyword. My own VSCode does not do this.
I have tried everything I can think of to find why this won't work for me, and I'm at a complete loss. I have compared my installation process to my friend's, followed the exact same steps I provided him for setting up his environment, and do not get the same results. I tried completely removing Python, VSCode and all residual VSCode files from my laptop, and reinstalling in the same order he did, still to no avail.
I followed those same steps on a different laptop at work, and I can get the MouseHover to work there. The only feasible difference I can think of is that my work machine is not using the same Windows account as both my home PC and laptop - but I do not have Settings Sync enabled so I can't see why that should matter anyway.
Any thoughts for what I'm overlooking to get this functionality working properly in VSCode for myself? I don't particularly need it, but I'd like to be in the same environment as my friend while I teach him.
We're both on VSCode 1.55.2, Python 3.9.4, using a virtual environment created from VSCode's Powershell terminal, then restarted VSCode to get it to detect the virtual environment and use it as default for Terminals, and finally pip installed and enabled Pylint as the linter.
Editing to add steps followed - I just went through all of this again on my home laptop, after completely removing all traces of VisualStudio2019 and Code, and Python. Note: this was on Windows 10, with all updates applied
Install VSCode
Install VSCode Python extension, MS version
Install Python 3.9.4
Open a new folder in VSCode, then open Terminal
python -m venv venv
create a something.py in the Explorer pane
VSCode should detect the venv and offer to load it. Say yes
VScode may also indiacte that pylint is not installed, Allow it to install, or manually pip install pylint from the venv.
in something.py type out import random
Mouse over import -- this is the discrepancy. On both of my home machines, there is no mousehover anything. on both of my friend's machines, as well as my machine at work, the following is shown:
With help from riov8's comment on the original post, I was able to compare the Experiment Groups that were in effect for each of the environments.
In VSCode, with a Python file loaded, switch to the Output panel (in same area as Terminal) and change the dropdown to Python.
Scroll to the top of this panel, and examine the Experiment Groups you belong to.
Most of the experiment groups do not apply to this issue.
Look specifically for either pythonJediLSP, pythonJediLSPcf or if
you have neither.
If you are experiencing the issue I describe, then at the bottom of this same panel, when you first mouse over a python keyword after starting VSCode, you will get errors similar to the following:
Error 2021-04-16 15:33:40: stderr jediProxy Error (stderr) %UserProfile%\.vscode\extensions\ms-python.python-2021.3.680753044\pythonFiles\completion.py:598: DeprecationWarning: Providing the line is now done in the functions themselves like `Script(...).complete(line, column)`
sys_path=sys.path,
%UserProfile%\.vscode\extensions\ms-python.python-2021.3.680753044\pythonFiles\completion.py:598: DeprecationWarning: Providing the column is now done in the functions themselves like `Script(...).complete(line, column)`
sys_path=sys.path,
Error 2021-04-16 15:33:40: stderr jediProxy Error (stderr) %UserProfile%\.vscode\extensions\ms-python.python-2021.3.680753044\pythonFiles\completion.py:598: DeprecationWarning: Deprecated since version 0.17.0. Use the project API instead, which means Script(project=Project(dir, sys_path=sys_path)) instead.
sys_path=sys.path,
Error 2021-04-16 15:33:40: stderr jediProxy Error (stderr) %UserProfile%\.vscode\extensions\ms-python.python-2021.3.680753044\pythonFiles\completion.py:626: DeprecationWarning: Deprecated since version 0.16.0. Use Script(...).infer instead.
script.goto_definitions(), request["id"]
The following scenarios resolved the issue for me:
User belongs to experiment group pythonJediLSPcf:
File > Preferences > Settings
in Search Settings, begin typing python.experiment
under Python> Experiments: Opt Out From, click Edit in settings.json
in the section "python.experiments.optOutFrom", add "pythonJediLSPcf" (quoted)
if it does not exist, add another section "python.experiments.optInto"
In the OptInto section, add "pythonJediLSP" (quoted)
Save the settings.json, and restart VSCode.
MouseHover tooltips on Python keywords now should work.
User does not belong to either pythonJediLSPcf or pythonJediLSP:
File > Preferences > Settings
in Search Settings, begin typing python.experiment
under Python › Experiments: Opt Into, click Edit in settings.json
In the "python.experiments.optInto section, add "pythonJediLSP" (quoted)
Save the settings.json, and restart VSCode.
MouseHover tooltips on Python keywords now should work.
User belongs to pythonJediLSP:
It was my experience that this was the experiment required in order for the feature to work properly. If you have this experiment enabled already, then ensure you do not also have pythonJediLSPcf. Disable it if you do, following the instructions in the first sub-heading. If it continues to not work, then there may be another conflict that I did not experience myself.
I am posting a GitHub issue regarding this problem and will update this answer with the link when done.
I recently installed VScode on Ubuntu, and now it doesnt automatically linter the code using the python interpreter (as it did on Windows). This is really annoying me because I have to save the file every time I want it to linter.
Any answers are greatly appreciated
If you need more info, just let me know and I will provide it
By default, linting for Python is enabled in Visual Studio Code using Pylint, and you can enable other linters of your choice. You can easily enable and disable all linting by using the Python: Enable Linting command. Also you can verify your linting settings:
Go to Settings and check the which linting rules you have enabled :
Go to Command Palette and check if the linter is enabled:
More info: https://code.visualstudio.com/docs/python/linting
There is a setting called Python: Jedi Enabled(looks like this). If you switch if off and then restart VSCode, the issue should be fixed
I am unable to use the debugger in PyCharm. Looking around for an answer, the first thing I came across was to use the project interpreter.
If I go to the top left, "Edit Configurations" and de-select "Use Project Interpreter", then the code runs just fine, but the option to debug is grayed-out.
If I select "Use project interpreter", then go to settings and set the project interpreter to be the same one, I can't run the code at all, let alone debug it. Upon selecting the option, the message "!Error: No project interpreter configured" pops up immediately... but it is configured!
Settings:
Run/Debug Configurations:
Followed these instructions to set up my project from an existing Conda environment: https://www.jetbrains.com/help/pycharm/conda-support-creating-conda-virtual-environment.html
I have made sure I clicked "apply" and also restarted PyCharm after that. This doesn't seem complicated, and at this point I have no idea what I can possibly be missing.
The error was caused because I was using the Bash template instead of the Python template to set up my run configuration. This occurred because I had previously used PyCharm to run a bash script, and the option to create a Python template was collapsed by default, leading me to not realize my mistake.
I've installed cx_Oracle 5.2.1 for Python 2.7.10, and it works (running Win). My problem is though; PyCharm notifies me that the module name does not exists, which is not a problem in runtime. But because of this PyCharm is unable to assist me on the modules different function etc.
Can anyone clarify please?
I already looked into this PyCharm: Python's standard lib's names and functions are underlined as "No module named such" and I though it might be related. I don't see any solution though.
EDIT 1:
I read that it might fix the problem to delete cx-Oracle from the Project Interpreter and add it again. Problem is though that I get an error trying to install cx_Oracle: error: command 'C:\\Program Files (x86)\\Common Files\\Microsoft\\Visual C++ for Python\\9.0\\VC\\Bin\\link.exe' failed with exit status 1120. I use PyCharm through a proxy.
EDIT 2:
As mentioned in a comment
import cx_Oracle
print cx_Oracle.__file__
yields C:\Python27\lib\site-packages\cx_Oracle.pyd, and you can see the Project Interpreter Paths here.
Go to File > Invalidate Caches > Invalidate and Restart or Invalidate and check.
If you want to check the library inside pyCharm go to File > Settings > Project > Project Interpreter. Select the interpreter and check the library is listed.
If you want to check the path where the said module is installed.
import cx_Oracle
print cx_Oracle.__file__
Open Pycharm
Go to File -> Settings -> Project interpreter
In the package column, click the pip package and find cx_Oracle from the list. Select it and click the install button, now it will work fine.
I'm using Eclipse (on the PyDev perspective), and I just installed (using pip) the python 'requests' module.
Eclipse is giving me an error warning on the 'import requests' line, saying that it is an unresolved import, but I've run it it imports just fine. (But the error message won't go away).
Its really bugging me, and I can't right-click and delete the error either. (The option is gray).
Is there any way to fix this? (Even if it involves manually removing the error?)
I know that there is a similar problem here:
Eclipse Pydev - Misdiplayed Import Error
but the answer to that was that PyDev had a bug specifically with PIL, so that is why I'm asking a different question.
Sometimes, PyDev is a little buggy... When it happens, I usually right-click on the folder containing the file in the PyDev Package Explorer, then "PyDev->remove error markers". And then re-run code analysis.
If it still doesn't work, try removing and adding again the directory to your requests module to the PyDev Path. As I said, PyDev is a little buggy...
You should manually configure properties of you PyDev project.
Right click on your project name, select PyDev - PYTHONPATH, then in External Libraries tab press Add source folder and choose the root directory of your library.