I am new to using Visual Code on Ubtuntu... But I followed all necessary instructions to install google app engine for python.
Then on writing my python code on the Visual Code, which I already modified my USER SETTINGS :
{
"python.autoComplete.extraPaths": [
"/usr/local/google_appengine",
"/usr/local/google_appengine/lib"],
"python.autoComplete.addBrackets": true,
"workbench.welcome.enabled": false,
"workbench.iconTheme": "vscode-icons",
"python.pythonPath": "/usr/bin/python",
}
Please how I can resolve this?
Add the following library paths to your "python.autoComplete.extraPaths" list:
"/usr/local/google_appengine/api",
"/usr/local/google_appengine/lib/webapp2-2.5.2"
Related
Pylance displays errors for Google Cloud SDK after I reinstalled Windows.
from google.appengine.ext import ndb
class Example(ndb.Model):
basic_example = ndb.StringProperty()
The first issue, up by the import:
Import "google.appengine.ext" could not be resolved Pylance (reportMissingImports)
I needed to add extraPaths for Cloud SDK. I've seen/tried various solutions and found this effective:
{ // settings.json
"python.analysis.extraPaths": [
"C:/Program Files (x86)/Google/Cloud SDK/google-cloud-sdk/platform/google_appengine"
],
"python.autoComplete.extraPaths": [
"C:/Program Files (x86)/Google/Cloud SDK/google-cloud-sdk/platform/google_appengine"
]
}
Current issue, where the library is used; all over the code.
"Model" is not a known member of module Pylance (reportGeneralTypeIssues)
"StringProperty" is not a known member of module Pylance (reportGeneralTypeIssues)
I see no way forward.
The project ran Python 2.7 while Pylance required 3.0.
im useing Python (3.9) in combination with Microsoft Visual Studio Community 2019
Version 16.7.7
I try to use an example to write a config file. https://tutswiki.com/read-write-config-files-in-python/
Visual Studio is reporting me an syntax error at the keywords "open" an "as" and the ":" in the end of the line. Marks it red. There also is no highlight on the "with" and the "as" statement.
If i force Visual Studio to run anyway, it is running fine.
Does anyone know, what's the problem Visual Studio is reporting and how to fix it.
from configparser import ConfigParser
#Get the configparser object
config_object = ConfigParser()
#Assume we need 2 sections in the config file, let's call them USERINFO and SERVERCONFIG
config_object["USERINFO"] = {
"admin": "Chankey Pathak",
"loginid": "chankeypathak",
"password": "tutswiki"
}
config_object["SERVERCONFIG"] = {
"host": "tutswiki.com",
"port": "8080",
"ipaddr": "8.8.8.8"
}
#Write the above sections to config.ini file
with open('config.ini', 'w') as conf:
config_object.write(conf)
Thank you Silvio, you pushed me in the correct direction.
I added Python 3.9 (64Bit) to my project. While installation of Visual Studio i also selected the 64Bit version of Python3 (not the latest version available--> 3.7.8).
But Visual Studios installation path is:
C:\Program Files (x86)\Microsoft Visual Studio\2019\Community\Common7\IDE\devenv.exe
Because of the "(x86)" i tried to install the 32bit Python3 while installation of Visual Studio.
Now it works fine!
I have an app named "diary" in my Django project:
school_diary/
diary/
<standart files inside app>
views.py
forms.py
Inside my views.py I make this import:
from . import forms
PyLint marks it as error. Here's what I have inside my settings.json:
{
...,
"python.linting.enabled": true,
"on.linting.pylintEnabled": true,
"python.linting.lintOnSave": true,
"python.linting.maxNumberOfProblems": 200,
"python.linting.pylintPath": "/home/alantheknight/Python/Environments/secenv/bin/pylint",
"python.pythonPath": "/home/alantheknight/Python/Environments/secenv/bin/python3.7",
...
Also, I read about generating .pylintrc, so I ran this command:
$ pylint --generate-rcfile > ~/.pylintrc
Where have I made a mistake?
This is a common error that most people come across.
You have not installed pylint in the same environment that contains your python packages.
The environment selected in VS Code is displayed at the bottom left on the status bar of VS Code.
Take a look at stackoverflow/pylint-unable-to-import-error-how-to-set-pythonpath.
and also pythonVSCodeDocs/docs/troubleshooting_linting
I am running pylint on an opencv project and I am getting many pylint errors in VS code about members not being present.
Example code:
import cv2
cv2.imshow(....)
Errors obtained:
However , the code runs correctly without any errors.
Versions : pylint 1.8.1 , astroid 1.6.0
This is from pylint. You can generate a pylint config file in the root of your project with this command:
(I find this to be helpful if you work in a team or on different computers from the same repo)
pylint --generate-rcfile > ~/.pylintrc
At the beginning of the generated .pylintrc file you will see
# A comma-separated list of package or module names from where C extensions may
# be loaded. Extensions are loading into the active Python interpreter and may
# run arbitrary code.
extension-pkg-whitelist=
Add cv2 so you end up with
# A comma-separated list of package or module names from where C extensions may
# be loaded. Extensions are loading into the active Python interpreter and may
# run arbitrary code.
extension-pkg-whitelist=cv2
Save the file.
The lint errors should disappear.
On VScode: CTRL + Shift + P
Choose "Preferences: Open Settings (JSON)"
Add this line into JSON file:
"python.linting.pylintArgs": ["--generate-members"]
Done, it works for me
Note: Make sure you choose "Preferences: Open Settings (JSON)", not "Preferences: Open Default Settings (JSON)"
Setting File would look like
{
"workbench.iconTheme": "vscode-icons",
"python.dataScience.sendSelectionToInteractiveWindow": true,
"kite.showWelcomeNotificationOnStartup": false,
"python.dataScience.askForKernelRestart": false,
"python.dataScience.jupyterServerURI": "local",
"python.pythonPath": "/usr/bin/python3",
"workbench.colorTheme": "Monokai",
"vsicons.dontShowNewVersionMessage": true,
"python.linting.pylintArgs": ["--generate-members"] }
Try import cv2 like this:
from cv2 import cv2
Yes it is because the extension has not been installed.
Set this: extension-pkg-whitelist=cv2 and you're good to go.
However it may not detect the functions or modules implemented in cv2
Here the code snippet for the settings.json file in MS V Code
"python.linting.pylintArgs":["--extension-pkg-whitelist=cv2"]
I didn't have to change anything in the pylint Jason file like the most of the answers here My solution is to change the import statement to the form below
from cv2 import cv2
Eventually, cv2 members can be used!
In VSCode, edit the Settings JSON (Ctrl+Shift+P, > "Preferences: Open Settings JSON)
Then, paste the following into the JSON:
"python.linting.pylintArgs": [
... // prievious arguments
"--generated-members=cv2.*"
]
Don't know why, but other solutions (allowlist, etc) weren't working for me, and I didn't want ot create the .pylintrc file.
I used below config settings in settings.json of vscode and it helped me avoid the unessential flags by pylint, and also got intellisense for cv2 working,
it it doesn't work try uninstalling and deleting cv2 packages from C:\Anaconda3\envs\demo1\Lib\site-packages folder, and reinstalling opencv-python package
{
"python.linting.pylintEnabled": true,
"python.linting.enabled": true,
"python.linting.pylintArgs": [
"--extension-pkg-whitelist=cv2"
]
}
I've created a program that pulls information from routers using SNMP (via PySNMP module). The application works great and I now what to compile it into a standalone application so that I can distribute it to my co-workers. However, after trying both Py2exe and PyInstaller, I've been unsuccessful in compiling a working application. I have searched the internet (a lot!) trying to find an example of someone who has successfully been able to compile their PySNMP application, but haven't been able to find anyway. Is there a better way to compile this or am I just doing it wrong?
These are the modules I've imported:
from Tkinter import *
import tkMessageBox
from pysnmp.entity.rfc3413.oneliner import cmdgen
This is the setup.py I've created for Py2exe:
from distutils.core import setup
import py2exe
setup( console = [
{ "script": "RSSIChecker.py",
}],
options = {
"py2exe":{
'includes': [
'pysnmp.smi.mibs.*',
'pysnmp.smi.mibs.instances.*'
]
}
}
)
Any suggestions?
With the following setup.py, a pysnmp-based app can be packaged with py2exe right out of the box (see line 101 and below). There are also some additional modules added implicitly into py2exe packaging as they are used by the app, not pysnmp itself.