[英]Python/pip bad interpreter : no such file or directory
I seem to have lost all the python packages that I had on my Mac. 我似乎丢失了Mac上所有的python软件包。
I entered the command below to upgrade from python3.6 to python3.7: 我在下面输入了从python3.6升级到python3.7的命令:
brew upgrade python
and now when I enter ipython3
in the terminal it says: 现在,当我在终端中输入ipython3
时,它说:
-bash: /usr/local/bin/ipython3: /usr/local/opt/python/bin/python3.6: bad interpreter: No such file or directory
However I was able to use ipython3
moments before I performed the brew upgrade. 但是,在执行ipython3
升级之前,我能够使用ipython3
瞬间。 Furthermore, I think I have lost all my python packages because when I do an import module in Python3, it says: 此外,我认为我已经丢失了所有python软件包,因为当我在Python3中执行导入模块时,它说:
ModuleNotFoundError: No module named *examplepythonpackage*
Are the python packages that I installed before all lost for good and do I have to re-install them individually now? 我之前安装的python软件包永久丢失了吗,我现在必须单独重新安装它们吗?
I also cannot run (in the bash terminal) $ ipython3
我也无法运行(在bash终端中)$ ipython3
-bash: /usr/local/bin/ipython3: /usr/local/opt/python/bin/python3.6: bad interpreter: No such file or directory
For reference: 以供参考:
$ which python
/usr/bin/python
$ which python3
/usr/local/bin/python3
$ pip --version
pip 18.1 from /Library/Python/2.7/site-packages/pip-18.1-py2.7.egg/pip (python 2.7)
$ pip3 --version
pip 18.1 from /usr/local/lib/python3.7/site-packages/pip (python 3.7)
The link between ipython
and which Python interpreter and libraries it uses underneath is established at installation time (as opposed to dynamically every time you run it), so I think your problem will be resolved if you remove and then re-install ipython
, ie: ipython
与其下面使用的Python解释器和库之间的链接是在安装时建立的(而不是每次运行时都动态地建立),因此,我认为如果删除然后重新安装ipython
,将解决您的问题,即:
brew rm ipython
brew install ipython
If you want to understand this, look at your ipython
script like this: 如果您想了解这一点,请查看您的ipython
脚本,如下所示:
more $(which ipython)
Your packages are not gone but are invisible to your new python. 您的软件包没有消失,但是对于新的python不可见。 You might try to trick python 3.7 into looking for packages inside the python3.6 directory but then many packages would not work, specifically extension packages since 3.6 and 3.7 are not ABI compatible. 您可能会尝试诱使python 3.7在python3.6目录中寻找软件包,但随后许多软件包将无法工作,尤其是扩展软件包,因为3.6和3.7与ABI不兼容。
Basically, an upgrade like this requires you to reinstall all packages. 基本上,这样的升级要求您重新安装所有软件包。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.