如何安装火把

2024-03-28 23:26:30 发布

您现在位置:Python中文网/ 问答频道 /正文

我创建了conda环境并安装了pytorch和fastai(Mac OS Mojave),如下所示:

conda create -n fai_course python=3.7
source activate fai_course
conda install -c pytorch pytorch-nightly-cpu
conda install -c fastai torchvision-nightly-cpu 
jupyter notebook

当我从jupyter notebook导入一个包时,我得到的OSError如下所示:

^{pr2}$

-

--------------------------------------------------------------------------
FileNotFoundError                         Traceback (most recent call last)
/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages/matplotlib/font_manager.py in <module>
   1352         try:
-> 1353             fontManager = json_load(_fmcache)
   1354             if (not hasattr(fontManager, '_version') or

/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages/matplotlib/font_manager.py in json_load(filename)
    887     """
--> 888     with open(filename, 'r') as fh:
    889         return json.load(fh, object_hook=_json_decode)

FileNotFoundError: [Errno 2] No such file or directory: '/Users/user/.matplotlib/fontlist-v300.json'

During handling of the above exception, another exception occurred:

OSError                                   Traceback (most recent call last)
<ipython-input-5-9f9378ae0f2a> in <module>
----> 1 from fastai.imports import *

/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages/fastai/__init__.py in <module>
----> 1 from .basic_train import *
      2 from .callback import *
      3 from .callbacks import *
      4 from .core import *
      5 from .data import *

/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages/fastai/basic_train.py in <module>
      1 "Provides basic training and validation with `Learner`"
----> 2 from .torch_core import *
      3 from .data import *
      4 from .callback import *
      5 

/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages/fastai/torch_core.py in <module>
      1 "Utility functions to help deal with tensors"
----> 2 from .imports.torch import *
      3 from .core import *
      4 
      5 AffineMatrix = Tensor

/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages/fastai/imports/__init__.py in <module>
----> 1 from .core import *
      2 from .torch import *

/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages/fastai/imports/core.py in <module>
      1 import csv, gc, gzip, os, pickle, shutil, sys, warnings
----> 2 import math, matplotlib.pyplot as plt, numpy as np, pandas as pd, random
      3 import scipy.stats, scipy.special
      4 import abc, collections, hashlib, itertools, json, operator
      5 import mimetypes, inspect, typing, functools

/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages/matplotlib/pyplot.py in <module>
     30 from cycler import cycler
     31 import matplotlib
---> 32 import matplotlib.colorbar
     33 import matplotlib.image
     34 from matplotlib import rcsetup, style

/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages/matplotlib/colorbar.py in <module>
     30 import matplotlib.collections as collections
     31 import matplotlib.colors as colors
---> 32 import matplotlib.contour as contour
     33 import matplotlib.cm as cm
     34 import matplotlib.gridspec as gridspec

/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages/matplotlib/contour.py in <module>
     16 import matplotlib.colors as mcolors
     17 import matplotlib.collections as mcoll
---> 18 import matplotlib.font_manager as font_manager
     19 import matplotlib.text as text
     20 import matplotlib.cbook as cbook

/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages/matplotlib/font_manager.py in <module>
   1361             raise
   1362         except Exception:
-> 1363             _rebuild()
   1364     else:
   1365         _rebuild()

/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages/matplotlib/font_manager.py in _rebuild()
   1342         global fontManager
   1343 
-> 1344         fontManager = FontManager()
   1345 
   1346         if _fmcache:

/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages/matplotlib/font_manager.py in __init__(self, size, weight)
    976         self.defaultFont = {}
    977 
--> 978         ttffiles = findSystemFonts(paths) + findSystemFonts()
    979         self.defaultFont['ttf'] = next(
    980             (fname for fname in ttffiles

/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages/matplotlib/font_manager.py in findSystemFonts(fontpaths, fontext)
    268             # check for OS X & load its fonts if present
    269             if sys.platform == 'darwin':
--> 270                 fontfiles.update(OSXInstalledFonts(fontext=fontext))
    271 
    272     elif isinstance(fontpaths, str):

/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages/matplotlib/font_manager.py in OSXInstalledFonts(directories, fontext)
    216         directories = OSXFontDirectories
    217     return [path
--> 218             for directory in directories
    219             for ext in get_fontext_synonyms(fontext)
    220             for path in list_fonts(directory, ext)]

/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages/matplotlib/font_manager.py in <listcomp>(.0)
    218             for directory in directories
    219             for ext in get_fontext_synonyms(fontext)
--> 220             for path in list_fonts(directory, ext)]
    221 
    222 

/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages/matplotlib/font_manager.py in list_fonts(directory, extensions)
    155     extensions = ["." + ext for ext in extensions]
    156     return [str(path)
--> 157             for path in filter(Path.is_file, Path(directory).glob("**/*.*"))
    158             if path.suffix in extensions]
    159 

/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages/matplotlib/font_manager.py in <listcomp>(.0)
    154     """
    155     extensions = ["." + ext for ext in extensions]
--> 156     return [str(path)
    157             for path in filter(Path.is_file, Path(directory).glob("**/*.*"))
    158             if path.suffix in extensions]

/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/pathlib.py in glob(self, pattern)
   1080             raise NotImplementedError("Non-relative patterns are unsupported")
   1081         selector = _make_selector(tuple(pattern_parts))
-> 1082         for p in selector.select_from(self):
   1083             yield p
   1084 

/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/pathlib.py in _select_from(self, parent_path, is_dir, exists, scandir)
    541             try:
    542                 successor_select = self.successor._select_from
--> 543                 for starting_point in self._iterate_directories(parent_path, is_dir, scandir):
    544                     for p in successor_select(starting_point, is_dir, exists, scandir):
    545                         if p not in yielded:

/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/pathlib.py in _iterate_directories(self, parent_path, is_dir, scandir)
    531                 if entry.is_dir() and not entry.is_symlink():
    532                     path = parent_path._make_child_relpath(entry.name)
--> 533                     for p in self._iterate_directories(path, is_dir, scandir):
    534                         yield p
    535         except PermissionError:

/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/pathlib.py in _iterate_directories(self, parent_path, is_dir, scandir)
    531                 if entry.is_dir() and not entry.is_symlink():
    532                     path = parent_path._make_child_relpath(entry.name)
--> 533                     for p in self._iterate_directories(path, is_dir, scandir):
    534                         yield p
    535         except PermissionError:

/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/pathlib.py in _iterate_directories(self, parent_path, is_dir, scandir)
    531                 if entry.is_dir() and not entry.is_symlink():
    532                     path = parent_path._make_child_relpath(entry.name)
--> 533                     for p in self._iterate_directories(path, is_dir, scandir):
    534                         yield p
    535         except PermissionError:

/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/pathlib.py in _iterate_directories(self, parent_path, is_dir, scandir)
    531                 if entry.is_dir() and not entry.is_symlink():
    532                     path = parent_path._make_child_relpath(entry.name)
--> 533                     for p in self._iterate_directories(path, is_dir, scandir):
    534                         yield p
    535         except PermissionError:

/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/pathlib.py in _iterate_directories(self, parent_path, is_dir, scandir)
    531                 if entry.is_dir() and not entry.is_symlink():
    532                     path = parent_path._make_child_relpath(entry.name)
--> 533                     for p in self._iterate_directories(path, is_dir, scandir):
    534                         yield p
    535         except PermissionError:

/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/pathlib.py in _iterate_directories(self, parent_path, is_dir, scandir)
    531                 if entry.is_dir() and not entry.is_symlink():
    532                     path = parent_path._make_child_relpath(entry.name)
--> 533                     for p in self._iterate_directories(path, is_dir, scandir):
    534                         yield p
    535         except PermissionError:

/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/pathlib.py in _iterate_directories(self, parent_path, is_dir, scandir)
    531                 if entry.is_dir() and not entry.is_symlink():
    532                     path = parent_path._make_child_relpath(entry.name)
--> 533                     for p in self._iterate_directories(path, is_dir, scandir):
    534                         yield p
    535         except PermissionError:

/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/pathlib.py in _iterate_directories(self, parent_path, is_dir, scandir)
    529             entries = list(scandir(parent_path))
    530             for entry in entries:
--> 531                 if entry.is_dir() and not entry.is_symlink():
    532                     path = parent_path._make_child_relpath(entry.name)
    533                     for p in self._iterate_directories(path, is_dir, scandir):

OSError: [Errno 62] Too many levels of symbolic links: '.Trash/NETGEARGenie.app/Contents/Frameworks/QtPrintSupport.framework/Versions/5/5'

你能告诉我我遗漏了什么吗? 谢谢


Tags: pathinpyimportselfformatplotlibis
2条回答

诚然,这个错误非常令人困惑。但是,看看库路径:

/库/框架/Python.framework/Versions/3.7/lib/Python3.7/

我猜您使用的不是通过conda安装的Jupyter,而是另一个本地安装。在

尝试检查您正在使用的Jupyter:

    which jupyter

应该是这样的:

~/anaconda3/bin/jupyter公司

如果不是这样,那么您使用的是另一个jupyter安装,它似乎没有安装这些库。在

如果您转到fastai github repo,您将看到以下内容:“NB:fastai v1目前只支持Linux,并且需要PyTorch v1和python3.6。。。

所以至少可以尝试用python3.6创建环境

或者像您从Python3.7开始那样,在本文中这样做:https://medium.com/@plape/how-to-install-fastai-on-mac-a05496670926

使用

conda install -c pytorch -c fastai fastai jupyter

而不是

conda install -c pytorch pytorch-nightly-cpu conda install -c fastai torchvision-nightly-cpu

希望这有帮助。在

相关问题 更多 >