Problem in importing : import pandas_market_calendars - python-3.x

After the installation of market calendar, when I import:
import pandas_market_calendars
I get following error:
ImportError: cannot import name 'apply_wraps' from 'pandas._libs.tslibs.offsets'

import pandas as pd
import pandas_market_calendars as mcal

Related

Pytest Error while Import "matplotlib.backends.backend_qt5agg" - pytest-qt

I have a created test file, test_sample.py. In that file I am trying to import the matplotlip package matplotlib.backends.backend_qt5agg, while running the pytest command it shows the following error. When I comment that import line, the pytest command will run successfully. But I should import that line.
test_sample.py file,
from PyQt5 import QtCore, QtGui, QtTest, QtWidgets
from PyQt5.QtCore import QCoreApplication, QObject, Qt
from PyQt5.QtWidgets import *
from pytestqt.plugin import QtBot
from matplotlib.backends.backend_qt5agg import FigureCanvasQTAgg as FigureCanvas
def test_method(self):
--------------
all the code
----------------
The following error,
test_sample.py:8: in <module>
from matplotlib.backends.backend_qt5agg import FigureCanvasQTAgg as FigureCanvas
..\esd_env\lib\site-packages\matplotlib\backends\backend_qt5agg.py:7: in <module>
from .backend_qtagg import ( # noqa: F401, E402 # pylint: disable=W0611
..\esd_env\lib\site-packages\matplotlib\backends\backend_qtagg.py:12: in <module>
from .backend_qt import QtCore, QtGui, _BackendQT, FigureCanvasQT
..\esd_env\lib\site-packages\matplotlib\backends\backend_qt.py:72: in <module>
_MODIFIER_KEYS = [
..\esd_env\lib\site-packages\matplotlib\backends\backend_qt.py:73: in <listcomp>
(_to_int(getattr(_enum("QtCore.Qt.KeyboardModifier"), mod)),
E TypeError: int() argument must be a string, a bytes-like object or a number, not 'KeyboardModifier'
I don't know why it end up with this error. This import works successfully when I run the application. It cause an error only on running testcases using commandpytest.
Note I have installed matplotlip==3.6.0
Kindly help me to fix this issue.

Python Selenium By raises AttributeError: type object 'By' has no attribute 'XPATH'

I have a problem with Selenium.
def main_test():
chrome_options = Options()
prefs = {"download.default_directory": f"{os.getcwd()}/Music"}
chrome_options.add_argument("user-data-dir=selenium")
chrome_options.add_experimental_option("prefs", prefs)
dr = webdriver.Chrome(options=chrome_options, service=Service(ChromeDriverManager().install()))
dr.get(URL)
print(f"{selenium.__version__=}")
dr.find_element(By.XPATH, "/html/body/div[1]/div[1]/div/div[1]/ul/li[2]/a").click()
dr.quit()
if __name__ == '__main__':
main_test()
This is my code. I think i followed properly the documentation. Although, when running the app i get this error:
selenium.__version__='4.6.0'
Traceback (most recent call last):
File "/Users/andrea/Dev/Python/custom_scripts/ytchannel/main.py", line 142, in <module>
main_test()
File "/Users/andrea/Dev/Python/custom_scripts/ytchannel/main.py", line 137, in main_test
dr.find_element(By.XPATH, "/html/body/div[1]/div[1]/div/div[1]/ul/li[2]/a").click()
AttributeError: type object 'By' has no attribute 'XPATH'
I have no clue on what i'm doing wrong...
I can add every detail possible if needed.
EDIT:
Here my imports:
import socket
import httpcore
import re
import os
import json
import selenium
import httpx as web
from selenium import webdriver
from selenium.webdriver.chrome.options import Options
from selenium.webdriver.chrome.service import Service
from webdriver_manager.chrome import ChromeDriverManager
from selenium.webdriver.common.by import By
from bs4 import BeautifulSoup
from time import sleep
Your code looks correct.
Make sure you imported the By properly.
This import should be used:
from selenium.webdriver.common.by import By

ImportError: cannot import name 'RandomizedLasso' from 'sklearn.linear_model'

ImportError: cannot import name 'RandomizedLasso' from 'sklearn.linear_model' (C:\ProgramData\Anaconda3\lib\site-packages\sklearn\linear_model_init_.py)

Pandas ImportError

Whenever I try to import pandas as pd it shows the error
ImportError: cannot import name 'window' from 'pandas.core' (//anaconda3/lib/python3.7/site-packages/pandas/core/__init__.py)

ImportError: cannot import name 'mutual_info_classif'

I want to do feature selection using K-Best and scoring function 'mutual_info_classif' in scikitlearn. However I am not able to import this function because of this error:
ImportError: cannot import name 'mutual_info_classif'

Resources