python安装中的文件模块失败

时间:2019-01-08 22:03:23

标签: python pip

我有一个使用模块的代码,该模块又使用python模块“文件”。现在,当我运行代码时,出现错误-

File "c:\users\sss\appdata\local\programs\python\python36-32\lib\site-packages\enmscripting\common\element.py", line 3, in <module>
from file import FileResult

ModuleNotFoundError: No module named 'file'

因此,我随后进入控制台并运行了“导入文件”。果然我没有那个模块。

import file
Traceback (most recent call last):

File "<ipython-input-27-f5da65cb6f61>", line 1, in <module>
import file

ModuleNotFoundError: No module named 'file'

然后我继续使用pip安装文件。得到下面的错误。请指教。我已经搜索了很多,却找不到解决方法。

C:\Users\sss>pip install file
Collecting file
  Using cached https://files.pythonhosted.org/packages/0a/49/317ac8ed10afb25c4c24972ea4de4c5507d6b0ab13bca4941c9a0bdc64ea/file-0.3.0.tar.gz
Requirement already satisfied: cffi>=1.0.0 in c:\users\sss\appdata\local\programs\python\python36-32\lib\site-packages (from file)
Requirement already satisfied: pycparser in c:\users\sss\appdata\local\programs\python\python36-32\lib\site-packages (from cffi>=1.0.0->file)
Installing collected packages: file
  Running setup.py install for file ... error
    Complete output from command c:\users\sss\appdata\local\programs\python\python36-32\python.exe -u -c "import setuptools, tokenize;__file__='C:\\Users\\Public\\Documents\\Wonder
share\\CreatorTemp\\pip-build-fe5vpmot\\file\\setup.py';f=getattr(tokenize, 'open', open)(__file__);code=f.read().replace('\r\n', '\n');f.close();exec(compile(code, __file__, 'exec
'))" install --record C:\Users\Public\Documents\Wondershare\CreatorTemp\pip-jqpbad1d-record\install-record.txt --single-version-externally-managed --compile:
    running install
    running build
    running build_py
    creating build
    creating build\lib.win32-3.6
    creating build\lib.win32-3.6\file
    copying src\file\_libmagic_build.py -> build\lib.win32-3.6\file
    copying src\file\__init__.py -> build\lib.win32-3.6\file
    running egg_info
    writing src\file.egg-info\PKG-INFO
    writing dependency_links to src\file.egg-info\dependency_links.txt
    writing requirements to src\file.egg-info\requires.txt
    writing top-level names to src\file.egg-info\top_level.txt
    reading manifest file 'src\file.egg-info\SOURCES.txt'
    reading manifest template 'MANIFEST.in'
    warning: no previously-included files matching '*.py[cod]' found anywhere in distribution
    warning: no previously-included files matching '__pycache__' found anywhere in distribution
    warning: no previously-included files matching '*.so' found anywhere in distribution
    warning: no previously-included files matching '*.dylib' found anywhere in distribution
    writing manifest file 'src\file.egg-info\SOURCES.txt'
    running build_ext
    generating cffi module 'build\\temp.win32-3.6\\Release\\file._libmagic.c'
    creating build\temp.win32-3.6
    creating build\temp.win32-3.6\Release
    building 'file._libmagic' extension
    creating build\temp.win32-3.6\Release\build
    creating build\temp.win32-3.6\Release\build\temp.win32-3.6
    creating build\temp.win32-3.6\Release\build\temp.win32-3.6\Release
    C:\Program Files (x86)\Microsoft Visual Studio\2017\Community\VC\Tools\MSVC\14.16.27023\bin\HostX86\x86\cl.exe /c /nologo /Ox /W3 /GL /DNDEBUG /MD -Ic:\users\sss\appdata\local\
programs\python\python36-32\include -Ic:\users\sss\appdata\local\programs\python\python36-32\include "-IC:\Program Files (x86)\Microsoft Visual Studio\2017\Community\VC\Tools\MSVC\
14.16.27023\include" "-IC:\Program Files (x86)\Windows Kits\10\include\10.0.17763.0\ucrt" "-IC:\Program Files (x86)\Windows Kits\10\include\10.0.17763.0\shared" "-IC:\Program Files
 (x86)\Windows Kits\10\include\10.0.17763.0\um" "-IC:\Program Files (x86)\Windows Kits\10\include\10.0.17763.0\winrt" "-IC:\Program Files (x86)\Windows Kits\10\include\10.0.17763.0
\cppwinrt" /Tcbuild\temp.win32-3.6\Release\file._libmagic.c /Fobuild\temp.win32-3.6\Release\build\temp.win32-3.6\Release\file._libmagic.obj
    file._libmagic.c
    build\temp.win32-3.6\Release\file._libmagic.c(492): fatal error C1083: Cannot open include file: 'magic.h': No such file or directory
    error: command 'C:\\Program Files (x86)\\Microsoft Visual Studio\\2017\\Community\\VC\\Tools\\MSVC\\14.16.27023\\bin\\HostX86\\x86\\cl.exe' failed with exit status 2

再次安装了Magic。没变化-

C:\Users\sss>pip install libmagic
Collecting libmagic
  Downloading https://files.pythonhosted.org/packages/83/86/419ddfc3879b4565a60e0c75b6d19baec48428cbc2f15aca5320b3d136f6/libmagic-1.0.tar.gz
Installing collected packages: libmagic
  Running setup.py install for libmagic ... done
Successfully installed libmagic-1.0

错误-与以前相同

ile._libmagic.c
build\temp.win32-3.6\Release\file._libmagic.c(492): fatal error C1083: Cannot open include file: 'magic.h': No such file or directory
error: command 'C:\\Program Files (x86)\\Microsoft Visual Studio\\2017\\Community\\VC\\Tools\\MSVC\\14.16.27023\\bin\\HostX86\\x86\\cl.exe' failed with exit status 2

已解决- 我降级到Python 2.7,一切正常。看来Python 3.6存在一些兼容性问题。

1 个答案:

答案 0 :(得分:0)

已解决-我降级到Python 2.7,一切正常。看来Python 3.6存在一些兼容性问题。