ImportError: cannot import name 'app_commands' from 'discord' - python-3.x

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

Related

Pyinput is showing warning in code but showing error while running the code

Traceback (most recent call last):
File "C:\Users\encur\Python\os.py", line 5, in
from pynput.keyboard import Key, Controller
ModuleNotFoundError: No module named 'pynput'
The error states that you do not have pynput package installed.
To install pyinput, use the following command on your terminal/shell:
pip install pynput
Or refer to the pypi package page: https://pypi.org/project/pynput/

64bit MacOs After succesfully installing Pygame: ModuleNotFoundError: No module named 'pygame'

Python noob here. I've been trying to install pygame and pandas for a few hours now. Even with Conda I did not succeed. I have Python 3.8.5 installed.
I eventually tried through the terminal with these commands:
python -m pip install pygame==2.0.0.dev6
and
python -m pip install pandas
(this was a total guess by the way, but apparently it did something)
Results were succesfull:
Requirement already satisfied: pygame==2.0.0.dev6 in /opt/miniconda3/lib/python3.8/site-packages (2.0.0.dev6)
and
Successfully installed numpy-1.19.2 pandas-1.1.2 python-dateutil-2.8.1 pytz-2020.1
But, when I try to import either modules, I still get errors. Any ideas?
import pygame
Traceback (most recent call last):
File "<pyshell#1>", line 1, in <module>
import pygame
ModuleNotFoundError: No module named 'pygame'
import pandas
Traceback (most recent call last):
File "<pyshell#2>", line 1, in <module>
import pandas
ModuleNotFoundError: No module named 'pandas'
Do I need to move the modules to the script folder or something? Or what do I even move? Thanks!
Ok.. Got it thanks to #matt.. after succesfully installing pygame, find the environment in which pygame is installed by entering 'which python'.
In my case it returned:
/opt/miniconda3/bin/python
Now I needed to make sure the VS console was pointing at the same environment, by checking which python interpreter it was using and selecting the correct one. More info:
how to check and change environment in VS Code

dnspython: module not found in pycharm

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

Pandas not working: DataFrameGroupBy ; PanelGroupBy

I have just upgraded python and I cannot get pandas to run properly, please see below. Nothing appears to work.
Traceback (most recent call last): File
"/Library/Frameworks/Python.framework/Versions/3.8/lib/python3.8/site-packages/tqdm/_tqdm.py",
line 613, in pandas
from pandas.core.groupby.groupby import DataFrameGroupBy, \ ImportError: cannot import name 'DataFrameGroupBy' from
'pandas.core.groupby.groupby'
(/Library/Frameworks/Python.framework/Versions/3.8/lib/python3.8/site-packages/pandas/core/groupby/groupby.py)
During handling of the above exception, another exception occurred:
Traceback (most recent call last): File
"code/analysis/get_cost_matrix.py", line 23, in
tqdm.pandas() # Gives us nice progress bars File "/Library/Frameworks/Python.framework/Versions/3.8/lib/python3.8/site-packages/tqdm/_tqdm.py",
line 616, in pandas
from pandas.core.groupby import DataFrameGroupBy, \ ImportError: cannot import name 'PanelGroupBy' from 'pandas.core.groupby'
(/Library/Frameworks/Python.framework/Versions/3.8/lib/python3.8/site-packages/pandas/core/groupby/init.py)
I guess you are using an older version of tqdm. Try using a version above tqdm>=4.23.4.
The command using pip would be,
pip install tqdm --upgrade
The problem is with the 0.25.1 version of pandas. Consider downgrading it to 0.24.0.
For more information read this
pip install --upgrade pandas==0.24.0

import rpy2.ipython meet error ModuleNotFoundError: No module named 'IPython'

My python version is 3.6. my OS is windows. After install rpy2 module, when I type import rpy2, got no issue. But when type import rpy2.ipython, got error as below:
>>> import rpy2.ipython
Warning (from warnings module):
File "D:\Soft_app\Python\lib\site-packages\rpy2\ipython\rmagic.py", line 76
"either.")))
UserWarning: The Python package 'pandas' is strongly recommended when using `rpy2.ipython`. Unfortunately it could not be loaded, and we did not manage to load 'numpy' either.
Traceback (most recent call last):
File "<pyshell#3>", line 1, in <module>
import rpy2.ipython
File "D:\Soft_app\Python\lib\site-packages\rpy2\ipython\__init__.py", line 1, in <module>
from .rmagic import load_ipython_extension
File "D:\Soft_app\Python\lib\site-packages\rpy2\ipython\rmagic.py", line 81, in <module>
from IPython.core.displaypub import publish_display_data
ModuleNotFoundError: No module named 'IPython'
Can help to figure out what's issue??
It seems that you are missing Ipython and pandas. Installing them should resolve your issue.
Run "pip install ipython" to install Ipython and run "pip install pandas" to install pandas.
Hopefully, this will solve your problem.
Happy Coding ~

Resources