我正在使用python3
via linuxbrew
,今天似乎有一个关键的 python-update 将 python 3.7 完全替换为 3.8。
至于我的操作系统(Lubuntu 18.04 LTS):
Operating System: Ubuntu 18.04.4 LTS
Kernel: Linux 5.3.0-62-generic
Architecture: x86-64
这就是为什么我的所有 python 站点包的 pip-upgrade 都不起作用的原因:
pip list --outdated --format=freeze | grep -v '^\-e' | cut -d = -f 1 | xargs -n1 pip install -U
抛出的错误是:
# /home/andylu/Desktop/Shell/python_package_complete_update_via_homebrew_n_pip: /home/linuxbrew/.linuxbrew/bin/pip: /home/linuxbrew/.linuxbrew/opt/python/bin/python3.7: bad interpreter: No such file or directory
# WARNING: pip is being invoked by an old script wrapper. This will fail in a future version of pip.
# Please see https://github.com/pypa/pip/issues/5599 for advice on fixing the underlying issue.
# To avoid this problem you can invoke Python with '-m pip' instead of running pip directly.
# Defaulting to user installation because normal site-packages is not writeable
# ERROR: You must give at least one requirement to install (see "pip help install")
后来,我发现有一个新的python-version install。奇怪的是,创建了两个文件夹:
/home/linuxbrew/.linuxbrew/lib/python3.8
/home/linuxbrew/.linuxbrew/Cellar/python@3.8/3.8.3_2/lib/python3.8
由于新 python3.8 文件夹中的站点包非常空,我将所有站点包(> 1GB)从 remnant/residual python3.7 移动到新的 python3.8 文件夹。有了这个,我假设它们在 python 3.8 下也能正常工作,而不是全部删除并重新安装。
此外,我认为其中的站点包/home/linuxbrew/.linuxbrew/Cellar/python@3.8/3.8.3_2/lib/python3.8
似乎只是指向/home/linuxbrew/.linuxbrew/lib/python3.8
.
然后我将 pip package-update 命令更新为以下内容:
python3 -m pip list --outdated --format=freeze | grep -v '^\-e' | cut -d = -f 1 | xargs -n1 python3 -m pip install -U
这似乎有效。然而,在打开 VS Code 时,它总是在右下角声明“pylint linter 的路径无效”,即使路径存在:
USER:~/Desktop/Python/Scripts$ which pylint
/home/linuxbrew/.linuxbrew/bin/pylint
USER:~/Desktop/Python/Scripts$ which python
/usr/bin/python
USER:~/Desktop/Python/Scripts$ which python3
/home/linuxbrew/.linuxbrew/bin/python3
接下来,在通过 Ctrl + Alt + P 在 VS Code 中执行 python 脚本时,会发生以下错误(以及整个输出):
USER:~/Desktop/Python/Scripts$
/home/linuxbrew/.linuxbrew/bin/python3 -c "from IPython import start_ipython; start_ipython()" /home/cripts/Master/Import_export/AERMET/import_and_manip_sitespec_meteodata_AERMET.py
---------------------------------------------------------------------------
ModuleNotFoundError Traceback (most recent call last)
/home/linuxbrew/.linuxbrew/lib/python3.8/site-packages/numpy/core/__init__.py in <module>
21 try:
---> 22 from . import multiarray
23 except ImportError as exc:
/home/linuxbrew/.linuxbrew/lib/python3.8/site-packages/numpy/core/multiarray.py in <module>
11
---> 12 from . import overrides
13 from . import _multiarray_umath
/home/linuxbrew/.linuxbrew/lib/python3.8/site-packages/numpy/core/overrides.py in <module>
6
----> 7 from numpy.core._multiarray_umath import (
8 add_docstring, implement_array_function, _get_implementing_args)
ModuleNotFoundError: No module named 'numpy.core._multiarray_umath'
During handling of the above exception, another exception occurred:
ImportError Traceback (most recent call last)
~/Dokumente/Allgemeines_material/Sonstiges/Programming/Python/Scripts/Master/Import_export/AERMET/import_and_manip_sitespec_meteodata_AERMET.py in <module>
40
41 import re
---> 42 import numpy as np
43 import pandas as pd
44 from tqdm import tqdm
/home/linuxbrew/.linuxbrew/lib/python3.8/site-packages/numpy/__init__.py in <module>
138 from . import _distributor_init
139
--> 140 from . import core
141 from .core import *
142 from . import compat
/home/linuxbrew/.linuxbrew/lib/python3.8/site-packages/numpy/core/__init__.py in <module>
46 """ % (sys.version_info[0], sys.version_info[1], sys.executable,
47 __version__, exc)
---> 48 raise ImportError(msg)
49 finally:
50 for envkey in env_added:
ImportError:
IMPORTANT: PLEASE READ THIS FOR ADVICE ON HOW TO SOLVE THIS ISSUE!
Importing the numpy C-extensions failed. This error can happen for
many reasons, often due to issues with your setup or how NumPy was
installed.
We have compiled some common reasons and troubleshooting tips at:
https://numpy.org/devdocs/user/troubleshooting-importerror.html
Please note and check the following:
* The Python version is: Python3.8 from "/home/linuxbrew/.linuxbrew/opt/python@3.8/bin/python3.8"
* The NumPy version is: "1.19.0"
and make sure that they are the versions you expect.
Please carefully study the documentation linked above for further help.
Original error was: No module named 'numpy.core._multiarray_umath'
尽管如此,numpy
它已经是最新的:
USER:~/Desktop/Python/Scripts$ pip install numpy
Requirement already satisfied: numpy in /home/linuxbrew/.linuxbrew/lib/python3.8/site-packages (1.19.0)
此外,在 的settings.json
文件中VS Code
,我声明为了安全起见,请执行以下操作:
"python.autoComplete.extraPaths": [
"/home/andylu/Dokumente/Allgemeines_material/Sonstiges/Programming/Python/Scripts",
"/home/linuxbrew/.linuxbrew/lib/python3.8/site-packages",
"/home/linuxbrew/.linuxbrew/Cellar/python@3.8/3.8.3_2/lib/python3.8/site-packages"
]
在我的 .bashrc - 文件中,我已经无济于事地更新了所有内容:
# Link to own and official python scripts and packages
export PYTHONPATH=/home/andylu/Dokumente/Allgemeines_material/Sonstiges/Programming/Python/Scripts:/home/linuxbrew/.linuxbrew/lib/python3.8/site-packages:/home/linuxbrew/.linuxbrew/Cellar/python@3.8/3.8.3_2/lib/python3.8/site-packages
# Homebrew
export PATH="/home/linuxbrew/.linuxbrew/bin:$PATH"
所有这些问题让我完全措手不及,我感到完全失落。我今天想继续我的项目,但是已经在互联网上花费了 2 个小时,发现所提出的解决方案都不适合我,因此我在这里开始了这个问题。