环境配置
Published:
记录bug和debug
指令
pip
$pip install -r requirements.txt
- 路径:
$Looking in indexes: https://pypi.tuna.tsinghua.edu.cn/simple, https://mirrors.aliyun.com/pypi/simple/, https://pypi.tuna.tsinghua.edu.cn/simple/
ERROR & SOLLUTION
ERROR1
$pip install -r requirements.txt
- ERROR 内容
ERROR: Ignored the following versions that require a different python version: 1.11.0 Requires-Python <3.13,>=3.9; 1.11.0rc1 Requires-Python <3.13,>=3.9; 1.11.0rc2 Requires-Python <3.13,>=3.9; 1.11.1 Requires-Python <3.13,>=3.9; 1.11.2 Requires-Python <3.13,>=3.9; 1.11.3 Requires-Python <3.13,>=3.9; 1.11.4 Requires-Python >=3.9; 1.12.0 Requires-Python >=3.9; 1.12.0rc1 Requires-Python >=3.9; 1.12.0rc2 Requires-Python >=3.9; 1.13.0 Requires-Python >=3.9; 1.13.0rc1 Requires-Python >=3.9; 1.13.1 Requires-Python >=3.9; 1.14.0 Requires-Python >=3.10; 1.14.0rc1 Requires-Python >=3.10; 1.14.0rc2 Requires-Python >=3.10; 1.14.1 Requires-Python >=3.10; 1.15.0 Requires-Python >=3.10; 1.15.0rc1 Requires-Python >=3.10; 1.15.0rc2 Requires-Python >=3.10; 1.15.1 Requires-Python >=3.10; 1.15.2 Requires-Python >=3.10; 1.25.0 Requires-Python >=3.9; 1.25.1 Requires-Python >=3.9; 1.25.2 Requires-Python >=3.9; 1.26.0 Requires-Python <3.13,>=3.9; 1.26.1 Requires-Python <3.13,>=3.9; 1.26.2 Requires-Python >=3.9; 1.26.3 Requires-Python >=3.9; 1.26.4 Requires-Python >=3.9; 1.4.0 Requires-Python >=3.9; 1.4.0rc1 Requires-Python >=3.9; 1.4.1.post1 Requires-Python >=3.9; 1.4.2 Requires-Python >=3.9; 1.5.0 Requires-Python >=3.9; 1.5.0rc1 Requires-Python >=3.9; 1.5.1 Requires-Python >=3.9; 1.5.2 Requires-Python >=3.9; 1.6.0 Requires-Python >=3.9; 1.6.0rc1 Requires-Python >=3.9; 1.6.1 Requires-Python >=3.9; 2.0.0 Requires-Python >=3.9; 2.0.1 Requires-Python >=3.9; 2.0.2 Requires-Python >=3.9; 2.1.0 Requires-Python >=3.10; 2.1.0 Requires-Python >=3.9; 2.1.0rc0 Requires-Python >=3.9; 2.1.0rc1 Requires-Python >=3.10; 2.1.1 Requires-Python >=3.10; 2.1.1 Requires-Python >=3.9; 2.1.2 Requires-Python >=3.10; 2.1.2 Requires-Python >=3.9; 2.1.3 Requires-Python >=3.10; 2.1.3 Requires-Python >=3.9; 2.1.4 Requires-Python >=3.9; 2.2.0 Requires-Python >=3.10; 2.2.0 Requires-Python >=3.9; 2.2.0rc0 Requires-Python >=3.9; 2.2.0rc1 Requires-Python >=3.10; 2.2.1 Requires-Python >=3.10; 2.2.1 Requires-Python >=3.9; 2.2.2 Requires-Python >=3.10; 2.2.2 Requires-Python >=3.9; 2.2.3 Requires-Python >=3.10; 2.2.3 Requires-Python >=3.9; 2.2.4 Requires-Python >=3.10; 3.10.0 Requires-Python >=3.10; 3.10.0rc1 Requires-Python >=3.10; 3.10.1 Requires-Python >=3.10; 3.8.0 Requires-Python >=3.9; 3.8.0rc1 Requires-Python >=3.9; 3.8.1 Requires-Python >=3.9; 3.8.2 Requires-Python >=3.9; 3.8.3 Requires-Python >=3.9; 3.8.4 Requires-Python >=3.9; 3.9.0 Requires-Python >=3.9; 3.9.0rc2 Requires-Python >=3.9; 3.9.1 Requires-Python >=3.9; 3.9.1.post1 Requires-Python >=3.9; 3.9.2 Requires-Python >=3.9; 3.9.3 Requires-Python >=3.9; 3.9.4 Requires-Python >=3.9 ERROR: Could not find a version that satisfies the requirement matplotlib==3.8.4 (from versions: 0.86, 0.86.1, 0.86.2, 0.91.0, 0.91.1, 1.0.1, 1.1.0, 1.1.1, 1.2.0, 1.2.1, 1.3.0, 1.3.1, 1.4.0, 1.4.1rc1, 1.4.1, 1.4.2, 1.4.3, 1.5.0, 1.5.1, 1.5.2, 1.5.3, 2.0.0b1, 2.0.0b2, 2.0.0b3, 2.0.0b4, 2.0.0rc1, 2.0.0rc2, 2.0.0, 2.0.1, 2.0.2, 2.1.0rc1, 2.1.0, 2.1.1, 2.1.2, 2.2.0rc1, 2.2.0, 2.2.2, 2.2.3, 2.2.4, 2.2.5, 3.0.0rc2, 3.0.0, 3.0.1, 3.0.2, 3.0.3, 3.1.0rc1, 3.1.0rc2, 3.1.0, 3.1.1, 3.1.2, 3.1.3, 3.2.0rc1, 3.2.0rc3, 3.2.0, 3.2.1, 3.2.2, 3.3.0rc1, 3.3.0, 3.3.1, 3.3.2, 3.3.3, 3.3.4, 3.4.0rc1, 3.4.0rc2, 3.4.0rc3, 3.4.0, 3.4.1, 3.4.2, 3.4.3, 3.5.0b1, 3.5.0rc1, 3.5.0, 3.5.1, 3.5.2, 3.5.3, 3.6.0rc1, 3.6.0rc2, 3.6.0, 3.6.1, 3.6.2, 3.6.3, 3.7.0rc1, 3.7.0, 3.7.1, 3.7.2, 3.7.3, 3.7.4, 3.7.5) ERROR: No matching distribution found for matplotlib==3.8.4
- 解读–>PYTHON环境过低,无法找到matplotlib库的要求版本
- 思考–>当前Python的版本为3.8.20,找不到matplotlib要求版本可能是清华源、阿里源没更新,我并没有指定要求版本,为什么会选择3.8.4这个版本
尝试解决
- 更改为官方源:
$pip install --index-url https://pypi.org/simple matplotlib
,临时改变下载索引到官方源,matplotlib-3.7.5,下载了这个版本,强制要求3.8.4后报了和上面一样的错Looking in indexes: https://pypi.org/simple, https://mirrors.aliyun.com/pypi/simple/, https://pypi.tuna.tsinghua.edu.cn/simple/
(MissData) root@dl-3d3265892d623f96a2261462b6a1ea45-r0-a940ad52485c-0:~/work# pip install --index-url https://pypi.org/simple matplotlib==3.8.4 Looking in indexes: https://pypi.org/simple, https://mirrors.aliyun.com/pypi/simple/, https://pypi.tuna.tsinghua.edu.cn/simple/ ERROR: Ignored the following versions that require a different python version: 3.10.0 Requires-Python >=3.10; 3.10.0rc1 Requires-Python >=3.10; 3.10.1 Requires-Python >=3.10; 3.8.0 Requires-Python >=3.9; 3.8.0rc1 Requires-Python >=3.9; 3.8.1 Requires-Python >=3.9; 3.8.2 Requires-Python >=3.9; 3.8.3 Requires-Python >=3.9; 3.8.4 Requires-Python >=3.9; 3.9.0 Requires-Python >=3.9; 3.9.0rc2 Requires-Python >=3.9; 3.9.1 Requires-Python >=3.9; 3.9.1.post1 Requires-Python >=3.9; 3.9.2 Requires-Python >=3.9; 3.9.3 Requires-Python >=3.9; 3.9.4 Requires-Python >=3.9 ERROR: Could not find a version that satisfies the requirement matplotlib==3.8.4 (from versions: 0.86, 0.86.1, 0.86.2, 0.91.0, 0.91.1, 1.0.1, 1.1.0, 1.1.1, 1.2.0, 1.2.1, 1.3.0, 1.3.1, 1.4.0, 1.4.1rc1, 1.4.1, 1.4.2, 1.4.3, 1.5.0, 1.5.1, 1.5.2, 1.5.3, 2.0.0b1, 2.0.0b2, 2.0.0b3, 2.0.0b4, 2.0.0rc1, 2.0.0rc2, 2.0.0, 2.0.1, 2.0.2, 2.1.0rc1, 2.1.0, 2.1.1, 2.1.2, 2.2.0rc1, 2.2.0, 2.2.2, 2.2.3, 2.2.4, 2.2.5, 3.0.0rc2, 3.0.0, 3.0.1, 3.0.2, 3.0.3, 3.1.0rc1, 3.1.0rc2, 3.1.0, 3.1.1, 3.1.2, 3.1.3, 3.2.0rc1, 3.2.0rc3, 3.2.0, 3.2.1, 3.2.2, 3.3.0rc1, 3.3.0, 3.3.1, 3.3.2, 3.3.3, 3.3.4, 3.4.0rc1, 3.4.0rc2, 3.4.0rc3, 3.4.0, 3.4.1, 3.4.2, 3.4.3, 3.5.0b1, 3.5.0rc1, 3.5.0, 3.5.1, 3.5.2, 3.5.3, 3.6.0rc1, 3.6.0rc2, 3.6.0, 3.6.1, 3.6.2, 3.6.3, 3.7.0rc1, 3.7.0, 3.7.1, 3.7.2, 3.7.3, 3.7.4, 3.7.5) ERROR: No matching distribution found for matplotlib==3.8.4
- 使用
$pip install --no-cache-dir -r requirements.txt
重新下载索引上可获取的最新包–>失败 $conda create -n mymiss python=3.10
尝试重新建立环境–>成功了总结:不要用python3.8
大乌龙,目录错了,用了室友的requirements.txt,就说为什么指定了3.8.4,重新来过
ERROR2
- 内容:
$pyhon genereate_masked_data.py
(mymiss) root@dl-3d3265892d623f96a2261462b6a1ea45-r0-a940ad52485c-0:~/work/Replication Code Missing Financial Data/src# python generate_masked_data.py 15 [0.0979365 0.10056767 0.10072778 0.09966303 0.09974058 0.10073726 0.0993909 0.09854462 0.09975589 0.10093217 0.10060002 0.09982471 0.09993537 0.1012674 0.10088311 0.09990689 0.10058899 0.09955194 0.10052696 0.10039454 0.09949781 0.10017685 0.10119397 0.10173072 0.10000614 0.1026477 0.0988854 0.10069985 0.10208461 0.10146134 0.0992452 0.10060401 0.10091088 0.10174234 0.09950724 0.10014149 0.09988383 0.09751439 0.09998426 0.10085632 0.0985102 0.09980981 0.0987589 0.10016542 0.09930094] Traceback (most recent call last): File "/root/work/Replication Code Missing Financial Data/src/generate_masked_data.py", line 210, in <module> generate_MAR_missing_data(percentile_rank_chars, return_panel, chars, monthly_updates, dates) File "/root/work/Replication Code Missing Financial Data/src/generate_masked_data.py", line 99, in generate_MAR_missing_data imputation_utils.save_imputation(flags_panel, dates, permnos, chars, "MAR_flag_panel") File "/root/work/Replication Code Missing Financial Data/src/imputation_utils.py", line 151, in save_imputation np.savez(result_file_name, data=imputed_data, dates=dates, permnos=permnos, chars=chars) File "<__array_function__ internals>", line 180, in savez File "/root/.local/lib/python3.10/site-packages/numpy/lib/npyio.py", line 615, in savez _savez(file, args, kwds, False) File "/root/.local/lib/python3.10/site-packages/numpy/lib/npyio.py", line 712, in _savez zipf = zipfile_factory(file, mode="w", compression=compression) File "/root/.local/lib/python3.10/site-packages/numpy/lib/npyio.py", line 103, in zipfile_factory return zipfile.ZipFile(file, *args, **kwargs) File "/root/.local/conda/envs/mymiss/lib/python3.10/zipfile.py", line 1254, in __init__ self.fp = io.open(file, filemode) FileNotFoundError: [Errno 2] No such file or directory: '../data/imputation_cache/MAR_flag_panel.npz'
- 解决:手动在data下建了imputation_cache目录
ERROR3
- 错误内容
ERROR: pip's dependency resolver does not currently take into account all the packages that are installed. This behaviour is the source of the following dependency conflicts. category-encoders 2.7.0 requires scikit-learn<1.6.0,>=1.0.0, but you have scikit-learn 1.6.1 which is incompatible. pycaret 3.0.4 requires numpy<1.24,>=1.21, but you have numpy 2.1.3 which is incompatible. pycaret 3.0.4 requires pandas<2.0.0,>=1.3.0, but you have pandas 2.2.3 which is incompatible. pycaret 3.0.4 requires scikit-learn<1.3.0,>=1.0, but you have scikit-learn 1.6.1 which is incompatible. tabpfn-extensions 0.0.4 requires seaborn==0.12.2, but you have seaborn 0.13.2 which is incompatible.
- 分析,scikit-learn、numpy、pandas、seaborn版本有问题,但是tabpfn用不到把它删掉吧
- 创了个新环境直接过了
ERROR4
- 场景
$python generate_masked_data.py
- 内容
(finaltry) root@dl-3d3265892d623f96a2261462b6a1ea45-r0-a940ad52485c-0:~/work/Replication Code Missing Financial Data/src# python generate_masked_data.py 15 [0.0979365 0.10056767 0.10072778 0.09966303 0.09974058 0.10073726 0.0993909 0.09854462 0.09975589 0.10093217 0.10060002 0.09982471 0.09993537 0.1012674 0.10088311 0.09990689 0.10058899 0.09955194 0.10052696 0.10039454 0.09949781 0.10017685 0.10119397 0.10173072 0.10000614 0.1026477 0.0988854 0.10069985 0.10208461 0.10146134 0.0992452 0.10060401 0.10091088 0.10174234 0.09950724 0.10014149 0.09988383 0.09751439 0.09998426 0.10085632 0.0985102 0.09980981 0.0987589 0.10016542 0.09930094] Traceback (most recent call last): File "/root/work/Replication Code Missing Financial Data/src/generate_masked_data.py", line 211, in <module> generate_LOGIT_missing_data(percentile_rank_chars, return_panel, chars, monthly_updates, dates) File "/root/work/Replication Code Missing Financial Data/src/generate_masked_data.py", line 167, in generate_LOGIT_missing_data start_model_l = logit_models_and_masking.create_logit_model('START', np.copy(percentile_rank_chars), chars, File "/root/work/Replication Code Missing Financial Data/src/logit_models_and_masking.py", line 299, in create_logit_model result = lm.LogisticRegression(random_state=0, penalty='none', max_iter=1000).fit(X, Y) File "/root/.local/lib/python3.10/site-packages/sklearn/base.py", line 1382, in wrapper estimator._validate_params() File "/root/.local/lib/python3.10/site-packages/sklearn/base.py", line 436, in _validate_params validate_parameter_constraints( File "/root/.local/lib/python3.10/site-packages/sklearn/utils/_param_validation.py", line 98, in validate_parameter_constraints raise InvalidParameterError( sklearn.utils._param_validation.InvalidParameterError: The 'penalty' parameter of LogisticRegression must be a str among {'l1', 'elasticnet', 'l2'} or None. Got 'none' instead.
- 解决:到logit_models_and_masking.py中查到penalty=’none’改成penalty=None