firsttime poster on stack overflow. I wrote the following code:
import requests
from bs4 import BeautifulSoup
request=requests.get('https://www.bever.nl/p/msr-pocket-rocket-2-brander-MECCC70060.html?colour=658')
soup = BeautifulSoup(request.text, 'html.parser')
product_data = soup.find_all(class_='as-a-text as-a-text--s glossary-highlight')
product_weight = 0
for x in range(len(product_data)):
if 'Gewicht (g)' in product_data[x]:
product_weight = int(product_data[x+1].text)
print(product_weight)
But the console throws the following error:
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "C:\Users\Joop_\AppData\Local\Programs\Python\Python310\lib\runpy.py", line 196, in _run_module_as_main
return _run_code(code, main_globals, None,
File "C:\Users\Joop_\AppData\Local\Programs\Python\Python310\lib\runpy.py", line 86, in _run_code
exec(code, run_globals)
File "c:\Users\Joop_\.vscode\extensions\ms-python.python-2022.8.1\pythonFiles\lib\python\debugpy\__main__.py", line 45, in <module>
cli.main()
File "c:\Users\Joop_\.vscode\extensions\ms-python.python-2022.8.1\pythonFiles\lib\python\debugpy/..\debugpy\server\cli.py", line 444, in main
run()
File "c:\Users\Joop_\.vscode\extensions\ms-python.python-2022.8.1\pythonFiles\lib\python\debugpy/..\debugpy\server\cli.py", line 285, in run_file
runpy.run_path(target_as_str, run_name=compat.force_str("__main__"))
File "C:\Users\Joop_\AppData\Local\Programs\Python\Python310\lib\runpy.py", line 289, in run_path
return _run_module_code(code, init_globals, run_name,
File "C:\Users\Joop_\AppData\Local\Programs\Python\Python310\lib\runpy.py", line 96, in _run_module_code
_run_code(code, mod_globals, init_globals,
File "C:\Users\Joop_\AppData\Local\Programs\Python\Python310\lib\runpy.py", line 86, in _run_code
exec(code, run_globals)
File "c:\Users\Joop_\AppData\Local\Programs\Python\Python310\Projects\Bever script.py", line 1, in <module>
import requests
File "C:\Users\Joop_\AppData\Roaming\Python\Python310\site-packages\requests\__init__.py", line 45, in <module>
from .exceptions import RequestsDependencyWarning
File "C:\Users\Joop_\AppData\Roaming\Python\Python310\site-packages\requests\exceptions.py", line 9, in <module>
from .compat import JSONDecodeError as CompatJSONDecodeError
File "C:\Users\Joop_\AppData\Roaming\Python\Python310\site-packages\requests\compat.py", line 13, in <module>
import charset_normalizer as chardet
File "C:\Users\Joop_\AppData\Roaming\Python\Python310\site-packages\charset_normalizer\__init__.py", line 24, in <module>
from .api import from_bytes, from_fp, from_path, normalize
File "C:\Users\Joop_\AppData\Roaming\Python\Python310\site-packages\charset_normalizer\api.py", line 10, in <module>
from .cd import (
File "C:\Users\Joop_\AppData\Roaming\Python\Python310\site-packages\charset_normalizer\cd.py", line 7, in <module>
from .assets import FREQUENCIES
ImportError: cannot import name 'FREQUENCIES' from 'charset_normalizer.assets' (unknown location)
I'm pretty new to Python and I have no idea what's causing this problem. I have tried to reimport the modules, and I've even uninstalled python and reinstalled it. I have also tried to repair python using the installer.
It seems like this issue.
Check your pythonPath and recreat pipenv.
Related
I am trying to decompile a file but I have run into an error.
C:\Users\Owner>decompyle3 wvripper.pyc
Traceback (most recent call last):
File "c:\users\owner\appdata\local\programs\python\python38\lib\runpy.py", line 194, in _run_module_as_main
return _run_code(code, main_globals, None,
File "c:\users\owner\appdata\local\programs\python\python38\lib\runpy.py", line 87, in _run_code
exec(code, run_globals)
File "C:\Users\Owner\AppData\Local\Programs\Python\Python38\Scripts\decompyle3.exe\__main__.py", line 4, in <module>
File "c:\users\owner\appdata\local\programs\python\python38\lib\site-packages\decompyle3\__init__.py", line 48, in <module>
import decompyle3.semantics.pysource
File "c:\users\owner\appdata\local\programs\python\python38\lib\site-packages\decompyle3\semantics\pysource.py", line 139, in <module>
import decompyle3.parsers.main as python_parser
File "c:\users\owner\appdata\local\programs\python\python38\lib\site-packages\decompyle3\parsers\__init__.py", line 12, in <module>
from decompyle3.parsers.main import *
File "c:\users\owner\appdata\local\programs\python\python38\lib\site-packages\decompyle3\parsers\main.py", line 32, in <module>
from xdis import iscode, py_str2float
ImportError: cannot import name 'py_str2float' from 'xdis' (c:\users\owner\appdata\local\programs\python\python38\lib\site-packages\xdis\__init__.py)
Apparently, I cannot import a file. What should I do?
I believe py_str2float needs to be imported from xdis.magics as in this example: https://github.com/welchbj/formatic/blob/524aed11c33627eba51cff169d8210f01660a250/formatic/walkers/code_object_injection_walker.py#L12-L13
I have a script in Python that uses the multiprocessor library and it was running fine. Then the next day I decided to run it again but it gave memory errors, and page file is too small errors. The only thing I can think of that changed was my hard disk space and updates to windows.
I thought it might have to do with a windows update conflict so I uninstalled Python 3.8.3 and upgraded to 3.9 and updated all dependent packages as well as the C++ distributable.
The one thing I tried was reducing the number of workers by another 6 workers. It worked but obviously was slower. I normally operate with -4 workers from total, and it posed no issues. I even tried running with all other applications turned off and network disabled, still the problem persists with -4 cores. Works with -10 cores though. It seems like something happened that requires the script to use more memory which explains why reducing the number of process instances works. But is this a bug that's causing this?
Any help would be appreciated. Thank you!
Traceback (most recent call last):
File "C:\Users\david\AppData\Local\Programs\Python\Python39\lib\site-packages\pandas\__init__.py", line 30, in <module>
File "C:\Users\david\AppData\Local\Programs\Python\Python39\lib\multiprocessing\spawn.py", line 116, in spawn_main
File "C:\Users\david\AppData\Local\Programs\Python\Python39\lib\multiprocessing\spawn.py", line 116, in spawn_main
exitcode = _main(fd, parent_sentinel)
File "C:\Users\david\AppData\Local\Programs\Python\Python39\lib\multiprocessing\spawn.py", line 125, in _main
from pandas._libs import hashtable as _hashtable, lib as _lib, tslib as _tslib
exitcode = _main(fd, parent_sentinel)
File "C:\Users\david\AppData\Local\Programs\Python\Python39\lib\site-packages\pandas\_libs\__init__.py", line 13, in <module>
File "C:\Users\david\AppData\Local\Programs\Python\Python39\lib\multiprocessing\spawn.py", line 125, in _main
from pandas._libs.interval import Interval
File "pandas\_libs\interval.pyx", line 1, in init pandas._libs.interval
prepare(preparation_data)
File "C:\Users\david\AppData\Local\Programs\Python\Python39\lib\multiprocessing\spawn.py", line 236, in prepare
prepare(preparation_data)
File "C:\Users\david\AppData\Local\Programs\Python\Python39\lib\multiprocessing\spawn.py", line 236, in prepare
_fixup_main_from_path(data['init_main_from_path'])
File "C:\Users\david\AppData\Local\Programs\Python\Python39\lib\multiprocessing\spawn.py", line 287, in _fixup_main_from_path
_fixup_main_from_path(data['init_main_from_path'])
File "C:\Users\david\AppData\Local\Programs\Python\Python39\lib\multiprocessing\spawn.py", line 287, in _fixup_main_from_path
File "pandas\_libs\hashtable.pyx", line 1, in init pandas._libs.hashtable
main_content = runpy.run_path(main_path,
File "C:\Users\david\AppData\Local\Programs\Python\Python39\lib\runpy.py", line 268, in run_path
main_content = runpy.run_path(main_path,
File "C:\Users\david\AppData\Local\Programs\Python\Python39\lib\runpy.py", line 268, in run_path
File "pandas\_libs\missing.pyx", line 1, in init pandas._libs.missing
return _run_module_code(code, init_globals, run_name,
File "C:\Users\david\AppData\Local\Programs\Python\Python39\lib\runpy.py", line 97, in _run_module_code
return _run_module_code(code, init_globals, run_name,
File "C:\Users\david\AppData\Local\Programs\Python\Python39\lib\runpy.py", line 97, in _run_module_code
_run_code(code, mod_globals, init_globals,
File "C:\Users\david\AppData\Local\Programs\Python\Python39\lib\runpy.py", line 87, in _run_code
_run_code(code, mod_globals, init_globals,
File "C:\Users\david\AppData\Local\Programs\Python\Python39\lib\runpy.py", line 87, in _run_code
File "C:\Users\david\AppData\Local\Programs\Python\Python39\lib\site-packages\pandas\_libs\tslibs\__init__.py", line 30, in <module>
exec(code, run_globals)
exec(code, run_globals)
File "C:\Users\david\Documents\GitHub\nimbleheart\Modules\STRATTEST_MULTITRIAL_MASTER.py", line 18, in <module>
File "C:\Users\david\Documents\GitHub\nimbleheart\Modules\STRATTEST_MULTITRIAL_MASTER.py", line 18, in <module>
from .conversion import OutOfBoundsTimedelta, localize_pydatetime
File "pandas\_libs\tslibs\conversion.pyx", line 58, in init pandas._libs.tslibs.conversion
import pandas as pd
import pandas as pd
File "C:\Users\david\AppData\Local\Programs\Python\Python39\lib\site-packages\pandas\__init__.py", line 52, in <module>
File "C:\Users\david\AppData\Local\Programs\Python\Python39\lib\site-packages\pandas\__init__.py", line 52, in <module>
File "pandas\_libs\tslibs\parsing.pyx", line 1, in init pandas._libs.tslibs.parsing
from pandas.core.api import (
from pandas.core.api import (
File "C:\Users\david\AppData\Local\Programs\Python\Python39\lib\site-packages\pandas\core\api.py", line 15, in <module>
File "C:\Users\david\AppData\Local\Programs\Python\Python39\lib\site-packages\pandas\core\api.py", line 29, in <module>
from pandas.core.arrays import Categorical
File "pandas\_libs\tslibs\offsets.pyx", line 1, in init pandas._libs.tslibs.offsets
File "C:\Users\david\AppData\Local\Programs\Python\Python39\lib\site-packages\pandas\core\arrays\__init__.py", line 10, in <module>
from pandas.core.groupby import Grouper, NamedAgg
File "C:\Users\david\AppData\Local\Programs\Python\Python39\lib\site-packages\pandas\core\groupby\__init__.py", line 1, in <module>
from pandas.core.arrays.interval import IntervalArray
File "C:\Users\david\AppData\Local\Programs\Python\Python39\lib\site-packages\pandas\core\arrays\interval.py", line 43, in <module>
from pandas.core.groupby.generic import DataFrameGroupBy, NamedAgg, SeriesGroupBy
File "C:\Users\david\AppData\Local\Programs\Python\Python39\lib\site-packages\pandas\core\groupby\generic.py", line 57, in <module>
File "pandas\_libs\tslibs\timestamps.pyx", line 47, in init pandas._libs.tslibs.timestamps
from pandas.core.indexes.base import ensure_index
File "C:\Users\david\AppData\Local\Programs\Python\Python39\lib\site-packages\pandas\core\indexes\base.py", line 31, in <module>
from pandas.core.aggregation import (
File "C:\Users\david\AppData\Local\Programs\Python\Python39\lib\site-packages\pandas\core\aggregation.py", line 27, in <module>
from pandas.core.dtypes import concat as _concat
File "C:\Users\david\AppData\Local\Programs\Python\Python39\lib\site-packages\pandas\core\dtypes\concat.py", line 25, in <module>
from pandas.core.series import FrameOrSeriesUnion, Series
ImportError: DLL load failed while importing fields: The paging file is too small for this operation to complete.
File "C:\Users\david\AppData\Local\Programs\Python\Python39\lib\site-packages\pandas\core\series.py", line 68, in <module>
The above exception was the di
None that I am aware of. There has been some issues with Panda 1.0.3 (when I last used it) on Windows which broke depending on the DLL locations/fallbacks etc. I would try installing the latest Microsoft Visual C++ Redistributable for Visual Studio 2015, 2017 and 2019 and see if that works (you already did, just re-iterating the steps I took). Could be the Windows update removed/updated something...
You might also try to copy concrt140.dll and msvcp140.dll from C:\Windows\System32 to pandas_libs\windows folder if you already have the latest installed.
Last resort would be to revert Pandas and/or Python to a known working copy (for me it was 1.0.1 and python 3.7)
I can't use the pip command but python is installed properly.
Traceback (most recent call last):
File "c:\users\personal\appdata\local\programs\python\python38-32\lib\runpy.py", line 193, in _run_module_as_main
return _run_code(code, main_globals, None,
File "c:\users\personal\appdata\local\programs\python\python38-32\lib\runpy.py", line 86, in _run_code
exec(code, run_globals)
File "C:\Users\PERSONAL\AppData\Local\Programs\Python\Python38-32\Scripts\pip3.exe\__main__.py", line 5, in <module>
File "c:\users\personal\appdata\local\programs\python\python38-32\lib\site-packages\pip\_internal\__init__.py", line 19, in <module>
from pip._vendor.urllib3.exceptions import DependencyWarning
File "c:\users\personal\appdata\local\programs\python\python38-32\lib\site-packages\pip\_vendor\urllib3\__init__.py", line 7, in <module>
from .connectionpool import (
File "c:\users\personal\appdata\local\programs\python\python38-32\lib\site-packages\pip\_vendor\urllib3\connectionpool.py", line 30, in <module>
from .connection import (
File "c:\users\personal\appdata\local\programs\python\python38-32\lib\site-packages\pip\_vendor\urllib3\connection.py", line 39, in <module>
from .util.ssl_ import (
ValueError: source code string cannot contain null bytes```
I want to install this script( https://github.com/SpEcHiDe/AnyDLBot)
on my server, but I was surprised that I cannot run any Python script and this error message appears to me every time I run the Python script :
(VENV) root#Hermania:/datadrive/AnyDLBot# python3 -m anydlbot Traceback (most recent call last):
File "/usr/lib/python3.5/runpy.py", line 184, in _run_module_as_main
"__main__", mod_spec)
File "/usr/lib/python3.5/runpy.py", line 85, in _run_code
exec(code, run_globals)
File "/datadrive/AnyDLBot/anydlbot/__main__.py", line 8, in <module>
from pyrogram import Client
File "/datadrive/AnyDLBot/VENV/lib/python3.5/site-packages/pyrogram/__init__.py", line 23, in <module>
from .client import *
File "/datadrive/AnyDLBot/VENV/lib/python3.5/site-packages/pyrogram/client/__init__.py", line 19, in <module>
from .client import Client
File "/datadrive/AnyDLBot/VENV/lib/python3.5/site-packages/pyrogram/client/client.py", line 40, in <module>
from pyrogram.client.methods.password.utils import compute_check
File "/datadrive/AnyDLBot/VENV/lib/python3.5/site-packages/pyrogram/client/methods/__init__.py", line 19, in <module>
from .bots import Bots
File "/datadrive/AnyDLBot/VENV/lib/python3.5/site-packages/pyrogram/client/methods/bots/__init__.py", line 19, in <module>
from .answer_callback_query import AnswerCallbackQuery
File "/datadrive/AnyDLBot/VENV/lib/python3.5/site-packages/pyrogram/client/methods/bots/answer_callback_query.py", line 20, in <module>
from pyrogram.client.ext import BaseClient
File "/datadrive/AnyDLBot/VENV/lib/python3.5/site-packages/pyrogram/client/ext/__init__.py", line 19, in <module>
from .base_client import BaseClient
File "/datadrive/AnyDLBot/VENV/lib/python3.5/site-packages/pyrogram/client/ext/base_client.py", line 28, in <module>
from ..parser import Parser
File "/datadrive/AnyDLBot/VENV/lib/python3.5/site-packages/pyrogram/client/parser/__init__.py", line 19, in <module>
from .parser import Parser
File "/datadrive/AnyDLBot/VENV/lib/python3.5/site-packages/pyrogram/client/parser/parser.py", line 23, in <module>
from .html import HTML
File "/datadrive/AnyDLBot/VENV/lib/python3.5/site-packages/pyrogram/client/parser/html.py", line 109, in <module>
class HTML:
File "/datadrive/AnyDLBot/VENV/lib/python3.5/site-packages/pyrogram/client/parser/html.py", line 110, in HTML
def __init__(self, client: Union["pyrogram.BaseClient", None]):
File "/usr/lib/python3.5/typing.py", line 552, in __getitem__
dict(self.__dict__), parameters, _root=True)
File "/usr/lib/python3.5/typing.py", line 512, in __new__
for t2 in all_params - {t1} if not isinstance(t2, TypeVar)):
File "/usr/lib/python3.5/typing.py", line 512, in <genexpr>
for t2 in all_params - {t1} if not isinstance(t2, TypeVar)):
File "/usr/lib/python3.5/typing.py", line 190, in __subclasscheck__
self._eval_type(globalns, localns)
File "/usr/lib/python3.5/typing.py", line 177, in _eval_type
eval(self.__forward_code__, globalns, localns),
File "<string>", line 1, in <module>
AttributeError: module 'pyrogram' has no attribute 'BaseClient'
For your information, I changed versions of Python, but I faced the same problem ☹️☹️☹️☹️☹️☹️
I am calling a python script from another python script,irrespective of the output the python script I am calling I get the following error in stderr,I googled but couldn't find anything concrete,am clueless as to why am getting this error?does anyone have any idea on how to fix it?
Traceback (most recent call last):
File "C:\Python27\lib\runpy.py", line 151, in _run_module_as_main
mod_name, loader, code, fname = _get_module_details(mod_name)
File "C:\Python27\lib\runpy.py", line 109, in _get_module_details
return _get_module_details(pkg_main_name)
File "C:\Python27\lib\runpy.py", line 101, in _get_module_details
loader = get_loader(mod_name)
File "C:\Python27\lib\pkgutil.py", line 464, in get_loader
return find_loader(fullname)
File "C:\Python27\lib\pkgutil.py", line 474, in find_loader
for importer in iter_importers(fullname):
File "C:\Python27\lib\pkgutil.py", line 430, in iter_importers
__import__(pkg)
File "C:\Python27\lib\site-packages\pip\__init__.py", line 14, in <module>
from pip.utils import get_installed_distributions, get_prog
File "C:\Python27\lib\site-packages\pip\utils\__init__.py", line 27, in <module>
from pip._vendor import pkg_resources
File "C:\Python27\lib\site-packages\pip\_vendor\pkg_resources\__init__.py", line 35,
import email.parser
File "C:\Python27\lib\email\parser.py", line 12, in <module>
from email.feedparser import FeedParser
File "C:\Python27\lib\email\feedparser.py", line 27, in <module>
from email import message
File "C:\Python27\lib\email\message.py", line 16, in <module>
import email.charset
File "C:\Python27\lib\email\charset.py", line 13, in <module>
import email.base64mime
File "C:\Python27\lib\email\base64mime.py", line 40, in <module>
from email.utils import fix_eols
File "C:\Python27\lib\email\utils.py", line 27, in <module>
import random
File "C:\Python27\lib\random.py", line 49, in <module>
import hashlib as _hashlib
File "C:\Python27\lib\hashlib.py", line 138, in <module>
_hashlib.openssl_md_meth_names)
AttributeError: 'module' object has no attribute 'openssl_md_meth_names'
Try to run brew cleanup and after that brew postinstall python.
For more info see this thread