我正在尝试运行Python脚本:
python main.py
获得此输出:
Traceback (most recent call last):
File "main.py", line 8, in <module>
import stateful
File "/path/to/s.py", line 599, in <module>
import policy as offloading_policy
File "/path/to/p.py", line 2, in <module>
from pacsltk import perfmodel
ModuleNotFoundError: No module named 'pacsltk'
Process finished with exit code 1
...但不仅已经安装了
pacsltk
:当我尝试安装它时(pip install pacsltk
),我得到:
Defaulting to user installation because normal site-packages is not writeable
Collecting pacsltk
Downloading pacsltk-0.2.0-py3-none-any.whl.metadata (2.3 kB)
Collecting boto3>=1.11.5 (from pacsltk)
Downloading boto3-1.35.54-py3-none-any.whl.metadata (6.7 kB)
Requirement already satisfied: numpy>=1.18.1 in ./.local/lib/python3.8/site-packages (from pacsltk) (1.24.4)
Requirement already satisfied: scipy>=1.4.1 in ./.local/lib/python3.8/site-packages (from pacsltk) (1.10.1)
Collecting botocore<1.36.0,>=1.35.54 (from boto3>=1.11.5->pacsltk)
Downloading botocore-1.35.54-py3-none-any.whl.metadata (5.7 kB)
Requirement already satisfied: jmespath<2.0.0,>=0.7.1 in ./.local/lib/python3.8/site-packages (from boto3>=1.11.5->pacsltk) (1.0.1)
Collecting s3transfer<0.11.0,>=0.10.0 (from boto3>=1.11.5->pacsltk)
Downloading s3transfer-0.10.3-py3-none-any.whl.metadata (1.7 kB)
Requirement already satisfied: python-dateutil<3.0.0,>=2.1 in ./.local/lib/python3.8/site-packages (from botocore<1.36.0,>=1.35.54->boto3>=1.11.5->pacsltk) (2.8.2)
Collecting urllib3<1.27,>=1.25.4 (from botocore<1.36.0,>=1.35.54->boto3>=1.11.5->pacsltk)
Downloading urllib3-1.26.20-py2.py3-none-any.whl.metadata (50 kB)
Requirement already satisfied: six>=1.5 in /usr/lib/python3/dist-packages (from python-dateutil<3.0.0,>=2.1->botocore<1.36.0,>=1.35.54->boto3>=1.11.5->pacsltk) (1.14.0)
WARNING: No metadata found in ./.local/lib/python3.8/site-packages
Downloading pacsltk-0.2.0-py3-none-any.whl (9.6 kB)
Downloading boto3-1.35.54-py3-none-any.whl (139 kB)
Downloading botocore-1.35.54-py3-none-any.whl (12.7 MB)
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 12.7/12.7 MB 901.6 kB/s eta 0:00:00
Downloading s3transfer-0.10.3-py3-none-any.whl (82 kB)
Downloading urllib3-1.26.20-py2.py3-none-any.whl (144 kB)
WARNING: Error parsing dependencies of attrs: [Errno 2] File o directory non esistente: '/home/username/.local/lib/python3.8/site-packages/attrs-23.1.0.dist-info/METADATA'
WARNING: Error parsing dependencies of urllib3: [Errno 2] File o directory non esistente: '/home/username/.local/lib/python3.8/site-packages/urllib3-2.0.4.dist-info/METADATA'
Installing collected packages: urllib3, botocore, s3transfer, boto3, pacsltk
Attempting uninstall: urllib3
WARNING: No metadata found in ./.local/lib/python3.8/site-packages
Found existing installation: urllib3 2.0.4
error: uninstall-no-record-file
× Cannot uninstall urllib3 2.0.4
╰─> The package's contents are unknown: no RECORD file was found for urllib3.
hint: You might be able to recover from this via: pip install --force-reinstall --no-deps urllib3==2.0.4
此外,当我尝试运行建议的命令
pip install --force-reinstall --no-deps urllib3==2.0.4
时,我只能获得相同的错误:
Defaulting to user installation because normal site-packages is not writeable
Collecting urllib3
Downloading urllib3-2.2.3-py3-none-any.whl.metadata (6.5 kB)
WARNING: No metadata found in ./.local/lib/python3.8/site-packages
Downloading urllib3-2.2.3-py3-none-any.whl (126 kB)
Installing collected packages: urllib3
Attempting uninstall: urllib3
WARNING: No metadata found in ./.local/lib/python3.8/site-packages
Found existing installation: urllib3 2.0.4
error: uninstall-no-record-file
× Cannot uninstall urllib3 2.0.4
╰─> The package's contents are unknown: no RECORD file was found for urllib3.
hint: You might be able to recover from this via: pip install --force-reinstall --no-deps urllib3==2.0.4
尝试
pip uninstall urllib3
时出现类似错误。
另外, sudo apt-get autoremove
/purge
应用于 python-urllib3
只是表示该软件包未安装。
与
urllib3
相同的错误似乎适用于我想要安装的任何 python 包。我已经查看了其他几个存在此错误的问题,但没有解决这个问题。我能做什么?
python 和 pip 包似乎已损坏。尝试以下方法:
让我知道它是否有效。 我安装了“scratch”,但遇到了完全相同的错误。然后我这样做了,它运行顺利。