NameError: name 'QgsMapLayerRegistry' is not defined - qgis

I am using Qgis 3.4.9. How can i fix To fix the error: NameError: global name 'QgsMapLayerRegistry' is not defined.
from qgis.core import QgsMapLayerRegistry
Is not working in Qgis 3.4.9
QgsMapLayerRegistry.instance().addMapLayer(point_layer)

QgsMapLayerRegistry: Its functionality has been moved to QgsProject.
Syntax:
QgsProject.instance().addMapLayer(your_Qgs_whaterver_Layer)
Example:
QgsProject.instance().addMapLayer(point_layer)

Related

VSCode wants to import library from folder, that doesn't exist because it has been renamed

I created a folder for my model called platform_Account.
After I created my model PlatformAccount there, I decided to rename it to platform_account_model.
When I now try to import my model to other files, I am getting this error:
List<PlatformAccount> accountList
The argument type 'List<PlatformAccount> (where PlatformAccount is defined in c:\Users\Wizzel\Desktop\project\lib\models\platform_account_model\platform_account_model.dart)' can't be assigned to the parameter type 'List<PlatformAccount> (where PlatformAccount is defined in c:\Users\Wizzel\Desktop\project\lib\models\platform_Account\platform_account.dart)'
.dartargument_type_not_assignable
list.dart(52, 16): List is defined in C:\Users\Wizzel\fvm\versions\2.8.1\bin\cache\pkg\sky_engine\lib\core\list.dart
platform_account_model.dart(8, 7): PlatformAccount is defined in c:\Users\Wizzel\Desktop\project\lib\models\platform_account_model\platform_account_model.dart
list.dart(52, 16): List is defined in C:\Users\Wizzel\fvm\versions\2.8.1\bin\cache\pkg\sky_engine\lib\core\list.dart
platform_account.dart(8, 7):
PlatformAccount is defined in c:\Users\Wizzel\Desktop\project\lib\models\platform_Account\platform_account.dart
but the platform_Account folder doesn't exist.
How do I fix this?
I fixed it by deleting all import statements and letting VSCode resolve the import paths again.

error when import torch-geometric module full path with constructor syntax required

I get the following error when I try to import torch-vision
FileNotFoundError: Could not find module 'C:\...site-packages\torch_sparse\_convert_cuda.pyd' (or one of its
dependencies). Try using the full path with constructor syntax.
however the '_convert_cuda.pyd' file does exist in the mentioned path

ModuleNotFoundError:No module name 'odoo.addons,base.res'

I got above error when I try to run the next code
from odoo import models, fields, api
from odoo.exceptions import ValidationError
from odoo.addons.base.res.res_request import referenceable_models
Because there is no res name module present in base module thats why it is giving an error

ImportError: cannot import name 'Template'

import numpy as np
from statistics import mean
x=[1,2,3,4,5]
y=[6,7,8,9,10]
m=((mean(x)*mean(y)-mean(x*y))/(mean(x)**2)-(mean(x**2)))
print(m)
In the above the(or any other code where I run numpy), Firstly I am getting an input request when running the program. Something like this:
PS D:\Codes\Python> python practice.py
Enter no.: 1
Enter: 1
which should not happen as values are initialized. I saw in other forums regarding how the file should not be named after a Python module(which you can see, it isn't). Even after that I'm getting error:
"C:\Users\KIIT\AppData\Local\Programs\Python\Python36\lib\logging\__init__.py", line 28, in <module>
from string import Template
ImportError: cannot import name 'Template'
Can someone please tell me what to do about it?
Edit:
This problem is only powershell centric. The problem is faced when I run program through powershell. It works fine in IDLE.
There must be a file named "string.py" in your D:\Codes\Python.
You can rename it to solve this issue.
You should not name the file to the modules in Python Standard Library.

Vue import failing

I've created a vue application scaffolded from the vue cli. Almost everything is reacting as expected with my app except for an issue with import.
The following works fine:
import Vuex from 'vuex';
but, this throws errors:
import { VuetronVue, VuetronVuex } from 'vuetron';
vue.use(VuetronVue);
Linting error:
"export 'VuetronVue' was not found in 'vuetron'
and Console error:
Uncaught TypeError: Cannot read property 'install' of undefined
Changing the code to:
import vuetron from 'vuetron'
vue.use(vuetron.VuetronVue);
resolves the issue...
This original code was taken directly from the Vuetron documentation. Does anyone have a suggestion as to why the ES6 notation would cause an issue?
This seems to be because
vuetron/packages/vuetron-plugins/index.js
only exports the default object:
import VuetronVue from './vuetron-vue';
import VuetronVuex from './vuetron-vuex';
export default {
VuetronVue,
VuetronVuex
};
For named imports as stated in the docs you would need a named export.