import pandas as pd
import re
from tqdm import tqdm
from ecommercetools import seo
Querylist1 = ['denmark, inflation',
'denmark, immigration',
'denmark, global warming',
'toronto, inflation',
'toronto, immigration',
'toronto, global warming',
'washington, inflation',
]
targets = []
for query in tqdm(Querylist1):
pages_num = 5
conditions = ['wikipedia','twitter','linkedin','facebook','news']
# Step 4.3: the main body.
try:
res = seo.get_serps(query, pages=pages_num)
except:
continue
for c in conditions[:]:
temp1 = res[res['link'].str.contains(c,case=False)]['title'].to_list()
temp2 = res[res['link'].str.contains(c,case=False)]['link'].to_list()
if len(temp1)==0:
y = ''
else:
y = temp1[0]
if len(temp2)==0:
z = ''
continue
else:
z = temp2[0]
targets.append([y,z,c,query])
targets = pd.DataFrame(targets, columns=['title','link','link category','query keyword used'])
print(targets)
这是一个简单的脚本。但是当我运行
pip install ecommercetools
时显示以下错误:
PS C:\Users\DELL\Desktop\New folder> pip install ecommercetools
Collecting ecommercetools
Using cached ecommercetools-0.42.9-py3-none-any.whl.metadata (54 kB)
Collecting gapandas (from ecommercetools)
Using cached gapandas-1.0-py3-none-any.whl.metadata (4.1 kB)
Collecting httplib2>=0.15.0 (from ecommercetools)
Using cached httplib2-0.22.0-py3-none-any.whl.metadata (2.6 kB)
Collecting lifetimes (from ecommercetools)
Using cached Lifetimes-0.11.3-py3-none-any.whl.metadata (4.8 kB)
Requirement already satisfied: numpy in c:\users\dell\appdata\local\programs\python\python311\lib\site-packages (from ecommercetools) (1.26.3)
Requirement already satisfied: pandas in c:\users\dell\appdata\local\programs\python\python311\lib\site-packages (from ecommercetools) (2.2.0)
Collecting pycausalimpact (from ecommercetools)
Using cached pycausalimpact-0.1.1-py2.py3-none-any.whl.metadata (8.3 kB)
Requirement already satisfied: requests in c:\users\dell\appdata\local\programs\python\python311\lib\site-packages (from ecommercetools) (2.31.0)
Requirement already satisfied: requests-html in c:\users\dell\appdata\local\programs\python\python311\lib\site-packages (from ecommercetools) (0.10.0)
Collecting sklearn (from ecommercetools)
Using cached sklearn-0.0.post12.tar.gz (2.6 kB)
Preparing metadata (setup.py) ... error
error: subprocess-exited-with-error
× python setup.py egg_info did not run successfully.
│ exit code: 1
╰─> [15 lines of output]
The 'sklearn' PyPI package is deprecated, use 'scikit-learn'
rather than 'sklearn' for pip commands.
Here is how to fix this error in the main use cases:
- use 'pip install scikit-learn' rather than 'pip install sklearn'
- replace 'sklearn' by 'scikit-learn' in your pip requirements files
(requirements.txt, setup.py, setup.cfg, Pipfile, etc ...)
- if the 'sklearn' package is used by one of your dependencies,
it would be great if you take some time to track which package uses
'sklearn' instead of 'scikit-learn' and report it to their issue tracker
- as a last resort, set the environment variable
SKLEARN_ALLOW_DEPRECATED_SKLEARN_PACKAGE_INSTALL=True to avoid this error
More information is available at
https://github.com/scikit-learn/sklearn-pypi-package
[end of output]
note: This error originates from a subprocess, and is likely not a problem with pip.
error: metadata-generation-failed
× Encountered error while generating package metadata.
╰─> See above for output.
note: This is an issue with the package mentioned above, not pip.
hint: See above for details.
我还安装了scikit-learn。但安装 ecommercetools 显示相同的错误。 我能看到的唯一可以理解的是:
Collecting sklearn (from ecommercetools)
Using cached sklearn-0.0.post12.tar.gz (2.6 kB)
Preparing metadata (setup.py) ... error
我认为当我运行
pip install ecommercetools
时,它会尝试安装默认的sklearn而不是我安装的新软件包(scikit-learn)
如有任何帮助,我们将不胜感激
如上所述
要用 scikit-learn 替换已弃用的 sklearn,请识别并更新依赖于过时功能的代码部分,并在需要时使用兼容的替代方案。检查更广泛的库兼容性并查看 scikit-learn 的文档以获取解决方案或解决方法。