美文网首页
PyCharm 许久不打开遇到的问题

PyCharm 许久不打开遇到的问题

作者: 烟影很美 | 来源:发表于2021-10-12 20:02 被阅读0次

1.pip list报错

dyld: Library not loaded: /usr/local/Cellar/python/3.7.3/Frameworks/Python.framework/Versions/3.7/Python
  Referenced from: /Users/daniel/Desktop/learn/DeepLearning-master/venv/bin/python
  Reason: image not found

原因是venv中的Python依赖的Python不存在了,不知道什么时候更新为Python3.9了。

解决办法:

> which python
/Users/daniel/Desktop/learn/DeepLearning-master/venv/bin/python

> otool -L /Users/daniel/Desktop/learn/DeepLearning-master/venv/bin/python
/Users/daniel/Desktop/learn/DeepLearning-master/venv/bin/python:
        /usr/local/Cellar/python/3.7.3/Frameworks/Python.framework/Versions/3.7/Python (compatibility version 3.7.0, current version 3.7.0)
        /usr/lib/libSystem.B.dylib (compatibility version 1.0.0, current version 1252.200.5)
        
> install_name_tool -change
/usr/local/Cellar/python/3.7.3/Frameworks/Python.framework/Versions/3.7/Python
/usr/local/Cellar/python@3.9/3.9.6/Frameworks/Python.framework/Versions/3.9/Python
/Users/daniel/Desktop/learn/DeepLearning-master/venv/bin/python

// install_name_tool [old] [new] [path]

2.pip list报错

Traceback (most recent call last):
  File "/Users/daniel/Desktop/learn/DeepLearning-master/venv/bin/pip3", line 7, in <module>
    from pip._internal.cli.main import main

好吧,就是pip list仍然报错。
网上有一个解决办法,就是使用vim编辑/Users/daniel/Desktop/learn/DeepLearning-master/venv/bin/pip3文件。

我这里是因为pip版本需要更新

运行如下命令:

> sudo python -m ensurepip
> sudo python -m pip install --upgrade pip

更新完成之后pip命令可以正常使用了。

3.pip更新之后,代码运行失败

报错:

Traceback (most recent call last):
  File "<input>", line 1, in <module>
  File "/Applications/PyCharm.app/Contents/helpers/pydev/_pydev_bundle/pydev_umd.py", line 198, in runfile
    pydev_imports.execfile(filename, global_vars, local_vars)  # execute the script
  File "/Applications/PyCharm.app/Contents/helpers/pydev/_pydev_imps/_pydev_execfile.py", line 18, in execfile
    exec(compile(contents+"\n", file, 'exec'), glob, loc)
  File "/Users/daniel/Desktop/learn/DeepLearning-master/learn04/tensorflow_learn_01.py", line 8, in <module>
    import tensorflow as tf

原因是pip更新之后旧的库不能使用了,自动新建了一个防止库的文件夹,里面什么都没得。


image.png

解决办法:
删掉旧的venv文件夹,然后在Python interpreter中重新添加一个,最后把需要的包重新安装一次。

截屏2021-10-13 14.15.23.png

4.运行Python代码报错

If this fails your Python may not be configured for Tk

解决办法:

# 终端运行
brew install python-tk

在Mac上使用此命令,其他系统参考:https://stackoverflow.com/questions/63643687/import-tkinter-if-this-fails-your-python-may-not-be-configured-for-tk-error-i

相关文章