dnspython: module not found in pycharm - python-3.x

I'm trying to connect to MongoDB from the pyCharm environment.
I'm using python 3.8 and I installed pymongo, dnspython and dnspython3.
My settings for the project are:
My code is:
from pymongo import MongoClient
import argparse
import dnspython
if __name__ == "__main__":
client = MongoClient("mongodb+srv://rajnesh:<myPassword>#cluster0-chffs.mongodb.net/test?authSource=admin&replicaSet=Cluster0-shard-0&readPreference=primary&appname=MongoDB%20Compass&ssl=true")
print("Hello there!")
However, I get the following Error:
Traceback (most recent call last): File
"/Users/rajnesh/pyProgram.py", line 17, in
import dnspython ModuleNotFoundError: No module named 'dnspython'
Process finished with exit code 1
Thanks in advance for your help.

For the dnspython package, the import name is "dns". More info about this can be found below:
http://www.dnspython.org/docs/1.16.0/
http://www.dnspython.org/examples.html

Related

ImportError: cannot import name 'app_commands' from 'discord'

For some reason I'm getting a error when importing app_commands
from discord import app_commands
Error message:
Traceback (most recent call last):
File "c:\Users\vwv42\OneDrive\Desktop\AutoMod\main.py", line 8, in <module>
from discord import app_commands
ImportError: cannot import name 'app_commands' from 'discord' (C:\Users\vwv42\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.10_qbz5n2kfra8p0\LocalCache\local-packages\Python310\site-packages\discord\__init__.py)
I would check that you have the beta of discord.py installed using:
pip show discord
If you get anything other than 2.0.0 you need to install the latest version which has app_commands
pip install git+https://github.com/Rapptz/discord.py
Could you try to update your python version? Updated from 3.7 and error is resolved for me

the correct way to use nornir plugins

I am a beginner with nornir, I am trying to run nornir plugins but I am having these errors:
Traceback (most recent call last):
File "nornirpy/start.py", line 2, in <module>
from nornir.plugins.tasks.commands import commands
ModuleNotFoundError: No module named 'nornir.plugins.tasks.commands'
My start.py file is very basic:
from nornir import InitNornir
from nornir.plugins.tasks.commands import commands
from nornir.core.inventory import Host
from path.to import InventoryPlugin
import json
nr = InitNornir("nornirpy/config.yml")
print(json.dumps(Host.schema(), indent=4))
What is the issue? I am using poetry to organize my project, is there a step I forgot? its not clear to me how can I use plugins in my application.
Hello Somayyah Mohammed;
First, check the version of nornir you are using. If version > 2.4.0 then module nornir.plugins.tasks.commands is not there. You can remove the import command it should work.

pyramid.config.Configurator() does not work with 'with' context manager

Is trying the quick start guide in pyramid website: https://trypyramid.com
from wsgiref.simple_server import make_server
from pyramid.config import Configurator
from pyramid.request import Response
def hello_world(request):
return Response('Hello World')
if __name__ == "__main__":
with Configurator() as config:
config.add_route('hello','/')
config.add_view(hello_world, route_name='hello')
app = config.make_wsgi_app()
server = make_server('0.0.0.0',6543,app)
Gives the following error:
/anaconda3/bin/python /Users/user1/Desktop/play/pyramid_play/tut_1/exp1.py
Traceback (most recent call last):
File "/Users/user1/Desktop/play/pyramid_play/tut_1/exp1.py", line 12, in <module>
with Configurator() as config:
AttributeError: __enter__
Process finished with exit code 1
Thanks Steve Piercy. This was an installation problem. I let pycharm install Pyramid while creating the project. pycharm used conda to install the package, which installed v1.5.7 (latest on conda repos) instead of the 1.9.1 (current version).
I installed pip to install the latest version which fixed the issue.

ImportError pyramid hello world program

source code:
from wsgiref.simple_server import make_server
from pyramid.config import Configurator
from pyramid.response import Response
def hello_world(request):
return Response('<h1>Hello world!</h1>')
if __name__ == '__main__':
config = Configurator()
config.add_view(hello_world)
app = config.make_wsgi_app()
server = make_server('0.0.0.0', 8080, app)
server.serve_forever()
When I ran the sample hello_world program using pyramid, I got the following error.
Traceback (most recent call last):
File "application.py", line 2, in <module>
from pyramid.config import Configurator
File "/usr/local/lib/python2.7/dist-packages/pyramid/config/__init__.py", line 12, in <module>
from pyramid.interfaces import (
File "/usr/local/lib/python2.7/dist-packages/pyramid/interfaces.py", line 3, in <module>
from zope.interface import (
ImportError: No module named interface
You've installed something improperly - more than likely by using python setup.py develop somewhere instead of using pip install -e .. If you mix tools you're going to have some issues. This particular one seems to be due to namespace packages not being configured correctly which almost always is a symptom of using easy_install and pip in the same environment. You need to pick one (preferably pip), and sometimes the decision about which one to use was already made by whatever tool installed python for you.

Import Error Using Pycahrm IDE

I am newbie to Python GUI using Qt libraries, I started learning PyQt development in Pycharm IDE I tried to run code-- started showing
C:\Python27\python.exe C:/Users/xxxx/PycharmProjects/initproject/helloworld 12:58, hello world
Traceback (most recent call last):
File "C:/Users/xxxx/PycharmProjects/initproject/helloworld", line 4, in <module>
from Pyside.QtCore import *
ImportError: No module named Pyside.QtCore
Process finished with exit code 1
I checked project Interpreter(using python 2.7) and also checked for installed packages(pip, setuptools- i found Pyside) but still its showing Error. Please help and thanks in advance.
I believe your mistake is simple: It is PySide and not Pyside. Try:
from PySide.QtCore import *
All package names and objects are case-sensitive.

Resources