Python:成功安装模块但无法通过导入获得

时间:2017-09-26 10:42:36

标签: python module pip install

我正在使用Jupyter Notebook,我想导入名为bluepyopt的外部工具箱。因为它目前只在Python 2.7中运行,所以我按照here的描述设置了一个Python 2.7内核。所以我可以在Jupyter Notebook中将我的内核更改为python 2。 如果我想使用

导入模块
import bluepyopt as bpop

我收到错误

ModuleNotFoundError                       Traceback (most recent call last)
<ipython-input-1-83e46e18aae9> in <module>()
      3 
      4 # to create electrical cell models
----> 5 import bluepyopt as bpop
      6 import bluepyopt.ephys as ephys
      7 

ModuleNotFoundError: No module named 'bluepyopt'

我按照

通常安装模块的方式安装 bluepyopt
!pip install bluepyopt

这也给了我一个非常的超级loooooong输出。我不知道什么是重要的,所以我会发布所有这些只是为了确定。这只发生在python 2.7中,然而,在python 3中一切正常!知道为什么会这样吗?

Collecting bluepyopt
Collecting efel>=2.11 (from bluepyopt)
  Using cached efel-2.12.11.tar.gz
Collecting ipyparallel (from bluepyopt)
  Using cached ipyparallel-6.0.2-py2.py3-none-any.whl
Requirement already satisfied: Jinja2>=2.8 in c:\users\alex\anaconda3\lib\site-packages (from bluepyopt)
Requirement already satisfied: pickleshare>=0.7.3 in c:\users\alex\anaconda3\lib\site-packages (from bluepyopt)
Requirement already satisfied: numpy>=1.6 in c:\users\alex\anaconda3\lib\site-packages (from bluepyopt)
Collecting scoop>=0.7 (from bluepyopt)
Requirement already satisfied: pandas>=0.18 in c:\users\alex\anaconda3\lib\site-packages (from bluepyopt)
Collecting future (from bluepyopt)
Requirement already satisfied: deap in c:\users\alex\anaconda3\lib\site-packages (from bluepyopt)
Requirement already satisfied: six in c:\users\alex\anaconda3\lib\site-packages (from efel>=2.11->bluepyopt)
Requirement already satisfied: ipython>=4 in c:\users\alex\anaconda3\lib\site-packages (from ipyparallel->bluepyopt)
Requirement already satisfied: ipykernel in c:\users\alex\anaconda3\lib\site-packages (from ipyparallel->bluepyopt)
Requirement already satisfied: python-dateutil>=2.1 in c:\users\alex\anaconda3\lib\site-packages (from ipyparallel->bluepyopt)
Requirement already satisfied: pyzmq>=13 in c:\users\alex\anaconda3\lib\site-packages (from ipyparallel->bluepyopt)
Requirement already satisfied: tornado>=4 in c:\users\alex\anaconda3\lib\site-packages (from ipyparallel->bluepyopt)
Requirement already satisfied: ipython-genutils in c:\users\alex\anaconda3\lib\site-packages (from ipyparallel->bluepyopt)
Requirement already satisfied: jupyter-client in c:\users\alex\anaconda3\lib\site-packages (from ipyparallel->bluepyopt)
Requirement already satisfied: decorator in c:\users\alex\anaconda3\lib\site-packages (from ipyparallel->bluepyopt)
Requirement already satisfied: MarkupSafe>=0.23 in c:\users\alex\anaconda3\lib\site-packages (from Jinja2>=2.8->bluepyopt)
Requirement already satisfied: greenlet>=0.3.4 in c:\users\alex\anaconda3\lib\site-packages (from scoop>=0.7->bluepyopt)
Collecting argparse>=1.1 (from scoop>=0.7->bluepyopt)
  Using cached argparse-1.4.0-py2.py3-none-any.whl
Requirement already satisfied: pytz>=2011k in c:\users\alex\anaconda3\lib\site-packages (from pandas>=0.18->bluepyopt)
Building wheels for collected packages: efel
  Running setup.py bdist_wheel for efel: started
  Running setup.py bdist_wheel for efel: finished with status 'error'
  Complete output from command C:\Users\Alex\Anaconda3\python.exe -u -c "import setuptools, tokenize;__file__='C:\\Users\\Alex\\AppData\\Local\\Temp\\pip-build-cygqwlch\\efel\\setup.py';f=getattr(tokenize, 'open', open)(__file__);code=f.read().replace('\r\n', '\n');f.close();exec(compile(code, __file__, 'exec'))" bdist_wheel -d C:\Users\Alex\AppData\Local\Temp\tmp5k5lqwx6pip-wheel- --python-tag cp36:
  running bdist_wheel
  running build
  running build_py
  creating build
  creating build\lib.win-amd64-3.6
  creating build\lib.win-amd64-3.6\efel
  copying efel\api.py -> build\lib.win-amd64-3.6\efel
  copying efel\io.py -> build\lib.win-amd64-3.6\efel
  copying efel\settings.py -> build\lib.win-amd64-3.6\efel
  copying efel\_version.py -> build\lib.win-amd64-3.6\efel
  copying efel\__init__.py -> build\lib.win-amd64-3.6\efel
  copying efel\DependencyV5.txt -> build\lib.win-amd64-3.6\efel
  creating build\lib.win-amd64-3.6\efel\cppcore
  copying efel\cppcore\Utils.h -> build\lib.win-amd64-3.6\efel\cppcore
  copying efel\cppcore\LibV1.h -> build\lib.win-amd64-3.6\efel\cppcore
  copying efel\cppcore\LibV2.h -> build\lib.win-amd64-3.6\efel\cppcore
  copying efel\cppcore\LibV3.h -> build\lib.win-amd64-3.6\efel\cppcore
  copying efel\cppcore\LibV4.h -> build\lib.win-amd64-3.6\efel\cppcore
  copying efel\cppcore\LibV5.h -> build\lib.win-amd64-3.6\efel\cppcore
  copying efel\cppcore\FillFptrTable.h -> build\lib.win-amd64-3.6\efel\cppcore
  copying efel\cppcore\DependencyTree.h -> build\lib.win-amd64-3.6\efel\cppcore
  copying efel\cppcore\efel.h -> build\lib.win-amd64-3.6\efel\cppcore
  copying efel\cppcore\cfeature.h -> build\lib.win-amd64-3.6\efel\cppcore
  copying efel\cppcore\Global.h -> build\lib.win-amd64-3.6\efel\cppcore
  copying efel\cppcore\mapoperations.h -> build\lib.win-amd64-3.6\efel\cppcore
  copying efel\cppcore\types.h -> build\lib.win-amd64-3.6\efel\cppcore
  copying efel\cppcore\eFELLogger.h -> build\lib.win-amd64-3.6\efel\cppcore
  UPDATING build\lib.win-amd64-3.6\efel/_version.py
  set build\lib.win-amd64-3.6\efel/_version.py to '2.12.11'
  running build_ext
  building 'efel.cppcore' extension
  error: Microsoft Visual C++ 14.0 is required. Get it with "Microsoft Visual C++ Build Tools": http://landinghub.visualstudio.com/visual-cpp-build-tools

  ----------------------------------------
  Running setup.py clean for efel
Failed to build efel
Installing collected packages: efel, ipyparallel, argparse, scoop, future, bluepyopt
  Running setup.py install for efel: started
    Running setup.py install for efel: finished with status 'error'
    Complete output from command C:\Users\Alex\Anaconda3\python.exe -u -c "import setuptools, tokenize;__file__='C:\\Users\\Alex\\AppData\\Local\\Temp\\pip-build-cygqwlch\\efel\\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\Alex\AppData\Local\Temp\pip-n69ud86n-record\install-record.txt --single-version-externally-managed --compile:
    running install
    running build
    running build_py
    creating build
    creating build\lib.win-amd64-3.6
    creating build\lib.win-amd64-3.6\efel
    copying efel\api.py -> build\lib.win-amd64-3.6\efel
    copying efel\io.py -> build\lib.win-amd64-3.6\efel
    copying efel\settings.py -> build\lib.win-amd64-3.6\efel
    copying efel\_version.py -> build\lib.win-amd64-3.6\efel
    copying efel\__init__.py -> build\lib.win-amd64-3.6\efel
    copying efel\DependencyV5.txt -> build\lib.win-amd64-3.6\efel
    creating build\lib.win-amd64-3.6\efel\cppcore
    copying efel\cppcore\Utils.h -> build\lib.win-amd64-3.6\efel\cppcore
    copying efel\cppcore\LibV1.h -> build\lib.win-amd64-3.6\efel\cppcore
    copying efel\cppcore\LibV2.h -> build\lib.win-amd64-3.6\efel\cppcore
    copying efel\cppcore\LibV3.h -> build\lib.win-amd64-3.6\efel\cppcore
    copying efel\cppcore\LibV4.h -> build\lib.win-amd64-3.6\efel\cppcore
    copying efel\cppcore\LibV5.h -> build\lib.win-amd64-3.6\efel\cppcore
    copying efel\cppcore\FillFptrTable.h -> build\lib.win-amd64-3.6\efel\cppcore
    copying efel\cppcore\DependencyTree.h -> build\lib.win-amd64-3.6\efel\cppcore
    copying efel\cppcore\efel.h -> build\lib.win-amd64-3.6\efel\cppcore
    copying efel\cppcore\cfeature.h -> build\lib.win-amd64-3.6\efel\cppcore
    copying efel\cppcore\Global.h -> build\lib.win-amd64-3.6\efel\cppcore
    copying efel\cppcore\mapoperations.h -> build\lib.win-amd64-3.6\efel\cppcore
    copying efel\cppcore\types.h -> build\lib.win-amd64-3.6\efel\cppcore
    copying efel\cppcore\eFELLogger.h -> build\lib.win-amd64-3.6\efel\cppcore
    UPDATING build\lib.win-amd64-3.6\efel/_version.py
    set build\lib.win-amd64-3.6\efel/_version.py to '2.12.11'
    running build_ext
    building 'efel.cppcore' extension
    error: Microsoft Visual C++ 14.0 is required. Get it with "Microsoft Visual C++ Build Tools": http://landinghub.visualstudio.com/visual-cpp-build-tools

    ----------------------------------------
  Failed building wheel for efel
Command "C:\Users\Alex\Anaconda3\python.exe -u -c "import setuptools, tokenize;__file__='C:\\Users\\Alex\\AppData\\Local\\Temp\\pip-build-cygqwlch\\efel\\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\Alex\AppData\Local\Temp\pip-n69ud86n-record\install-record.txt --single-version-externally-managed --compile" failed with error code 1 in C:\Users\Alex\AppData\Local\Temp\pip-build-cygqwlch\efel\
Requirement already satisfied: NEURON in c:\users\alex\anaconda3\lib\site-packages

在Jupyter Notebook中使用python 2内核时,还有一些有用的信息:

In [1]:
import sys
sys.executable

Out [1]:
'C:\\Users\\Alex\\Anaconda3\\envs\\ipykernel_py2\\python.exe'  #kernel python 2.7
'C:\\Users\\Alex\\Anaconda3\\python.exe' #kernel python 3

In [2]:
from jupyter_core.paths import jupyter_data_dir
print(jupyter_data_dir())

Out[2]:
C:\Users\Alex\AppData\Roaming\jupyter

In[3]:
sys.path

Out[3]:
['',
 'C:\\Users\\Alex\\Anaconda3\\envs\\ipykernel_py2\\python27.zip',
 'C:\\Users\\Alex\\Anaconda3\\envs\\ipykernel_py2\\DLLs',
 'C:\\Users\\Alex\\Anaconda3\\envs\\ipykernel_py2\\lib',
 'C:\\Users\\Alex\\Anaconda3\\envs\\ipykernel_py2\\lib\\plat-win',
 'C:\\Users\\Alex\\Anaconda3\\envs\\ipykernel_py2\\lib\\lib-tk',
 'C:\\Users\\Alex\\Anaconda3\\envs\\ipykernel_py2',
 'C:\\Users\\Alex\\Anaconda3\\envs\\ipykernel_py2\\lib\\site-packages',
 'C:\\Users\\Alex\\Anaconda3\\envs\\ipykernel_py2\\lib\\site-packages\\IPython\\extensions',
 'C:\\Users\\Alex\\.ipython']

In[4]:
!jupyter kernelspec list

Out[4]:
Available kernels:
  python3    C:\Users\Alex\Anaconda3\share\jupyter\kernels\python3
  python2    C:\ProgramData\jupyter\kernels\python2

1 个答案:

答案 0 :(得分:2)

我可以看到模块没有正确安装并且依赖于Microsoft Visual C ++ 14.0。

尝试从此链接http://landinghub.visualstudio.com/visual-cpp-build-tools

安装Microsoft Visual C ++构建工具

然后尝试再次使用pip安装模块

pip install bluepyopt