我正在使用 Ubuntu 18.04,Windows 10 双启动和 Python 3.6.8,所以我猜问题就是从那里开始的。当我尝试在 PyCharm 中运行一个文件时,它抛出了这个错误:
/usr/bin/python3: Error while finding module specification for 'temp.py' (AttributeError: module 'temp' has no attribute '__path__')
现在,我对 PyCharm 了解不多,所以我认为在终端上打开文件会更省时间,但终端却抛出了同样的错误。然后我尝试直接在终端上编写代码,所以我在终端上打开了 python 并进行了检查。它一直运行良好sys.version
,但当我输入 时import numpy
,它给了我这个:
# /home/vihangbodh/.local/lib/python3.6/site-packages/numpy/__pycache__/__init__.cpython-36.pyc matches /home/vihangbodh/.local/lib/python3.6/site-packages/numpy/__init__.py
# code object from '/home/vihangbodh/.local/lib/python3.6/site-packages/numpy/__pycache__/__init__.cpython-36.pyc'
# /home/vihangbodh/.local/lib/python3.6/site-packages/numpy/__pycache__/_globals.cpython-36.pyc matches /home/vihangbodh/.local/lib/python3.6/site-packages/numpy/_globals.py
# code object from '/home/vihangbodh/.local/lib/python3.6/site-packages/numpy/__pycache__/_globals.cpython-36.pyc'
import 'numpy._globals' # <_frozen_importlib_external.SourceFileLoader object at 0x7f41ebc3b400>
# /home/vihangbodh/.local/lib/python3.6/site-packages/numpy/__pycache__/__config__.cpython-36.pyc matches /home/vihangbodh/.local/lib/python3.6/site-packages/numpy/__config__.py
# code object from '/home/vihangbodh/.local/lib/python3.6/site-packages/numpy/__pycache__/__config__.cpython-36.pyc'
import 'numpy.__config__' # <_frozen_importlib_external.SourceFileLoader object at 0x7f41ebc3b780>
# /home/vihangbodh/.local/lib/python3.6/site-packages/numpy/__pycache__/version.cpython-36.pyc matches /home/vihangbodh/.local/lib/python3.6/site-packages/numpy/version.py
# code object from '/home/vihangbodh/.local/lib/python3.6/site-packages/numpy/__pycache__/version.cpython-36.pyc'
import 'numpy.version' # <_frozen_importlib_external.SourceFileLoader object at 0x7f41ebc3b908>
...
...
...
import 'gc' # <class '_frozen_importlib.BuiltinImporter'>
import 'numpy.testing._private.utils' # <_frozen_importlib_external.SourceFileLoader object at 0x7f41e0646940>
# /home/vihangbodh/.local/lib/python3.6/site-packages/numpy/testing/_private/__pycache__/decorators.cpython-36.pyc matches /home/vihangbodh/.local/lib/python3.6/site-packages/numpy/testing/_private/decorators.py
# code object from '/home/vihangbodh/.local/lib/python3.6/site-packages/numpy/testing/_private/__pycache__/decorators.cpython-36.pyc'
import 'numpy.testing._private.decorators' # <_frozen_importlib_external.SourceFileLoader object at 0x7f41e05d9940>
# /home/vihangbodh/.local/lib/python3.6/site-packages/numpy/testing/_private/__pycache__/nosetester.cpython-36.pyc matches /home/vihangbodh/.local/lib/python3.6/site-packages/numpy/testing/_private/nosetester.py
# code object from '/home/vihangbodh/.local/lib/python3.6/site-packages/numpy/testing/_private/__pycache__/nosetester.cpython-36.pyc'
import 'numpy.testing._private.nosetester' # <_frozen_importlib_external.SourceFileLoader object at 0x7f41e05ea550>
import 'numpy.testing' # <_frozen_importlib_external.SourceFileLoader object at 0x7f41e06bd3c8>
import 'numpy' # <_frozen_importlib_external.SourceFileLoader object at 0x7f41ef4faa20>
>>>
完整的终端输出是这里(这里超过了 30,000 个字符的限制),这看起来确实有些麻烦。我到底搞砸了什么?如果可以修复的话,该如何修复?
编辑:以下是输出apt policy
:
Package files:
100 /var/lib/dpkg/status
release a=now
500 http://repo.vivaldi.com/stable/deb stable/main i386 Packages
release o=Vivaldi Technologies,a=stable,l=Official Vivaldi package repository,c=main,b=i386
origin repo.vivaldi.com
500 http://repo.vivaldi.com/stable/deb stable/main amd64 Packages
release o=Vivaldi Technologies,a=stable,l=Official Vivaldi package repository,c=main,b=amd64
origin repo.vivaldi.com
500 http://repo.steampowered.com/steam precise/steam i386 Packages
release o=Valve Software LLC,n=precise,l=Steam,c=steam,b=i386
origin repo.steampowered.com
500 http://repo.steampowered.com/steam precise/steam amd64 Packages
release o=Valve Software LLC,n=precise,l=Steam,c=steam,b=amd64
origin repo.steampowered.com
500 https://packagecloud.io/slacktechnologies/slack/debian jessie/main i386 Packages
release v=1,o=packagecloud.io/slacktechnologies/slack,a=jessie,n=jessie,l=slack,c=main,b=i386
origin packagecloud.io
500 https://packagecloud.io/slacktechnologies/slack/debian jessie/main amd64 Packages
release v=1,o=packagecloud.io/slacktechnologies/slack,a=jessie,n=jessie,l=slack,c=main,b=amd64
origin packagecloud.io
500 http://ppa.launchpad.net/ondrej/php/ubuntu bionic/main i386 Packages
release v=18.04,o=LP-PPA-ondrej-php,a=bionic,n=bionic,l=***** The main PPA for supported PHP versions with many PECL extensions *****,c=main,b=i386
origin ppa.launchpad.net
500 http://ppa.launchpad.net/ondrej/php/ubuntu bionic/main amd64 Packages
release v=18.04,o=LP-PPA-ondrej-php,a=bionic,n=bionic,l=***** The main PPA for supported PHP versions with many PECL extensions *****,c=main,b=amd64
origin ppa.launchpad.net
500 https://repo.mongodb.org/apt/ubuntu bionic/mongodb-org/4.0/multiverse amd64 Packages
release o=mongodb,a=bionic,n=bionic/mongodb-org,l=mongodb,c=multiverse,b=amd64
origin repo.mongodb.org
500 http://ppa.launchpad.net/linrunner/tlp/ubuntu bionic/main i386 Packages
release v=18.04,o=LP-PPA-linrunner-tlp,a=bionic,n=bionic,l=TLP,c=main,b=i386
origin ppa.launchpad.net
500 http://ppa.launchpad.net/linrunner/tlp/ubuntu bionic/main amd64 Packages
release v=18.04,o=LP-PPA-linrunner-tlp,a=bionic,n=bionic,l=TLP,c=main,b=amd64
origin ppa.launchpad.net
500 http://ppa.launchpad.net/inkscape.dev/stable/ubuntu bionic/main i386 Packages
release v=18.04,o=LP-PPA-inkscape.dev-stable,a=bionic,n=bionic,l=Inkscape Stable,c=main,b=i386
origin ppa.launchpad.net
500 http://ppa.launchpad.net/inkscape.dev/stable/ubuntu bionic/main amd64 Packages
release v=18.04,o=LP-PPA-inkscape.dev-stable,a=bionic,n=bionic,l=Inkscape Stable,c=main,b=amd64
origin ppa.launchpad.net
500 http://dl.google.com/linux/chrome/deb stable/main amd64 Packages
release v=1.0,o=Google LLC,a=stable,n=stable,l=Google,c=main,b=amd64
origin dl.google.com
500 http://ppa.launchpad.net/apt-fast/stable/ubuntu bionic/main i386 Packages
release v=18.04,o=LP-PPA-apt-fast-stable,a=bionic,n=bionic,l=apt-fast stable PPA,c=main,b=i386
origin ppa.launchpad.net
500 http://ppa.launchpad.net/apt-fast/stable/ubuntu bionic/main amd64 Packages
release v=18.04,o=LP-PPA-apt-fast-stable,a=bionic,n=bionic,l=apt-fast stable PPA,c=main,b=amd64
origin ppa.launchpad.net
500 https://download.docker.com/linux/ubuntu bionic/stable amd64 Packages
release o=Docker,a=bionic,l=Docker CE,c=stable,b=amd64
origin download.docker.com
500 http://in.archive.ubuntu.com/ubuntu bionic-security/multiverse i386 Packages
release v=18.04,o=Ubuntu,a=bionic-security,n=bionic,l=Ubuntu,c=multiverse,b=i386
origin in.archive.ubuntu.com
500 http://in.archive.ubuntu.com/ubuntu bionic-security/multiverse amd64 Packages
release v=18.04,o=Ubuntu,a=bionic-security,n=bionic,l=Ubuntu,c=multiverse,b=amd64
origin in.archive.ubuntu.com
500 http://in.archive.ubuntu.com/ubuntu bionic-security/universe i386 Packages
release v=18.04,o=Ubuntu,a=bionic-security,n=bionic,l=Ubuntu,c=universe,b=i386
origin in.archive.ubuntu.com
500 http://in.archive.ubuntu.com/ubuntu bionic-security/universe amd64 Packages
release v=18.04,o=Ubuntu,a=bionic-security,n=bionic,l=Ubuntu,c=universe,b=amd64
origin in.archive.ubuntu.com
500 http://in.archive.ubuntu.com/ubuntu bionic-security/restricted i386 Packages
release v=18.04,o=Ubuntu,a=bionic-security,n=bionic,l=Ubuntu,c=restricted,b=i386
origin in.archive.ubuntu.com
500 http://in.archive.ubuntu.com/ubuntu bionic-security/restricted amd64 Packages
release v=18.04,o=Ubuntu,a=bionic-security,n=bionic,l=Ubuntu,c=restricted,b=amd64
origin in.archive.ubuntu.com
500 http://in.archive.ubuntu.com/ubuntu bionic-security/main i386 Packages
release v=18.04,o=Ubuntu,a=bionic-security,n=bionic,l=Ubuntu,c=main,b=i386
origin in.archive.ubuntu.com
500 http://in.archive.ubuntu.com/ubuntu bionic-security/main amd64 Packages
release v=18.04,o=Ubuntu,a=bionic-security,n=bionic,l=Ubuntu,c=main,b=amd64
origin in.archive.ubuntu.com
500 http://archive.canonical.com/ubuntu bionic/partner i386 Packages
release v=18.04,o=Canonical,a=bionic,n=bionic,l=Partner archive,c=partner,b=i386
origin archive.canonical.com
500 http://archive.canonical.com/ubuntu bionic/partner amd64 Packages
release v=18.04,o=Canonical,a=bionic,n=bionic,l=Partner archive,c=partner,b=amd64
origin archive.canonical.com
100 http://in.archive.ubuntu.com/ubuntu bionic-backports/universe i386 Packages
release v=18.04,o=Ubuntu,a=bionic-backports,n=bionic,l=Ubuntu,c=universe,b=i386
origin in.archive.ubuntu.com
100 http://in.archive.ubuntu.com/ubuntu bionic-backports/universe amd64 Packages
release v=18.04,o=Ubuntu,a=bionic-backports,n=bionic,l=Ubuntu,c=universe,b=amd64
origin in.archive.ubuntu.com
100 http://in.archive.ubuntu.com/ubuntu bionic-backports/main i386 Packages
release v=18.04,o=Ubuntu,a=bionic-backports,n=bionic,l=Ubuntu,c=main,b=i386
origin in.archive.ubuntu.com
100 http://in.archive.ubuntu.com/ubuntu bionic-backports/main amd64 Packages
release v=18.04,o=Ubuntu,a=bionic-backports,n=bionic,l=Ubuntu,c=main,b=amd64
origin in.archive.ubuntu.com
500 http://in.archive.ubuntu.com/ubuntu bionic-updates/multiverse i386 Packages
release v=18.04,o=Ubuntu,a=bionic-updates,n=bionic,l=Ubuntu,c=multiverse,b=i386
origin in.archive.ubuntu.com
500 http://in.archive.ubuntu.com/ubuntu bionic-updates/multiverse amd64 Packages
release v=18.04,o=Ubuntu,a=bionic-updates,n=bionic,l=Ubuntu,c=multiverse,b=amd64
origin in.archive.ubuntu.com
500 http://in.archive.ubuntu.com/ubuntu bionic-updates/universe i386 Packages
release v=18.04,o=Ubuntu,a=bionic-updates,n=bionic,l=Ubuntu,c=universe,b=i386
origin in.archive.ubuntu.com
500 http://in.archive.ubuntu.com/ubuntu bionic-updates/universe amd64 Packages
release v=18.04,o=Ubuntu,a=bionic-updates,n=bionic,l=Ubuntu,c=universe,b=amd64
origin in.archive.ubuntu.com
500 http://in.archive.ubuntu.com/ubuntu bionic-updates/restricted i386 Packages
release v=18.04,o=Ubuntu,a=bionic-updates,n=bionic,l=Ubuntu,c=restricted,b=i386
origin in.archive.ubuntu.com
500 http://in.archive.ubuntu.com/ubuntu bionic-updates/restricted amd64 Packages
release v=18.04,o=Ubuntu,a=bionic-updates,n=bionic,l=Ubuntu,c=restricted,b=amd64
origin in.archive.ubuntu.com
500 http://in.archive.ubuntu.com/ubuntu bionic-updates/main i386 Packages
release v=18.04,o=Ubuntu,a=bionic-updates,n=bionic,l=Ubuntu,c=main,b=i386
origin in.archive.ubuntu.com
500 http://in.archive.ubuntu.com/ubuntu bionic-updates/main amd64 Packages
release v=18.04,o=Ubuntu,a=bionic-updates,n=bionic,l=Ubuntu,c=main,b=amd64
origin in.archive.ubuntu.com
500 http://in.archive.ubuntu.com/ubuntu bionic/multiverse i386 Packages
release v=18.04,o=Ubuntu,a=bionic,n=bionic,l=Ubuntu,c=multiverse,b=i386
origin in.archive.ubuntu.com
500 http://in.archive.ubuntu.com/ubuntu bionic/multiverse amd64 Packages
release v=18.04,o=Ubuntu,a=bionic,n=bionic,l=Ubuntu,c=multiverse,b=amd64
origin in.archive.ubuntu.com
500 http://in.archive.ubuntu.com/ubuntu bionic/universe i386 Packages
release v=18.04,o=Ubuntu,a=bionic,n=bionic,l=Ubuntu,c=universe,b=i386
origin in.archive.ubuntu.com
500 http://in.archive.ubuntu.com/ubuntu bionic/universe amd64 Packages
release v=18.04,o=Ubuntu,a=bionic,n=bionic,l=Ubuntu,c=universe,b=amd64
origin in.archive.ubuntu.com
500 http://in.archive.ubuntu.com/ubuntu bionic/restricted i386 Packages
release v=18.04,o=Ubuntu,a=bionic,n=bionic,l=Ubuntu,c=restricted,b=i386
origin in.archive.ubuntu.com
500 http://in.archive.ubuntu.com/ubuntu bionic/restricted amd64 Packages
release v=18.04,o=Ubuntu,a=bionic,n=bionic,l=Ubuntu,c=restricted,b=amd64
origin in.archive.ubuntu.com
500 http://in.archive.ubuntu.com/ubuntu bionic/main i386 Packages
release v=18.04,o=Ubuntu,a=bionic,n=bionic,l=Ubuntu,c=main,b=i386
origin in.archive.ubuntu.com
500 http://in.archive.ubuntu.com/ubuntu bionic/main amd64 Packages
release v=18.04,o=Ubuntu,a=bionic,n=bionic,l=Ubuntu,c=main,b=amd64
origin in.archive.ubuntu.com
Pinned packages: