2017-09-26 5 views
0

J'utilise Jupyter Notebook et je veux importer une boîte à outils externe appelée bluepyopt. Comme il ne fonctionne actuellement qu'en Python 2.7, j'ai mis en place un noyau Python 2.7 comme décrit here. Je peux donc changer mon noyau en python 2 dans Jupyter Notebook. Si je veux importer le module en utilisantPython: installer un module avec succès mais il n'est pas disponible via l'import

import bluepyopt as bpop 

Je reçois l'erreur

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' 

installer bluepyopt la façon dont j'installe habituellement des modules avec

!pip install bluepyopt 

Cela donne aussi me une sortie super loooooong extraordinaire. Je ne sais pas ce qui est important ici, alors je vais tout afficher pour être sûr. Cela ne se produit que dans Python 2.7, mais en python 3 tout fonctionne bien! Une idée de pourquoi c'est comme ça?

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 

Quelques informations utiles peut-être lors de l'utilisation du noyau python 2 Jupyter Notebook:

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 
+0

double possible de [Erreur lors de l'installation lxml par pip: Microsoft Visual 14.0 C++ est requis] (https://stackoverflow.com/questions/38949519/error-while-installing-lxml-through-pip-microsoft-visual-c-14-0-is-required) – phd

Répondre

1

Comme je peux voir le module est pas correctement installé et la dépendance donnant pour Microsoft Visual C++ 14.0.

Essayez d'installer Microsoft Visual C++ construire des outils de ce lien http://landinghub.visualstudio.com/visual-cpp-build-tools

Ensuite, essayez d'installer le module à l'aide pip à nouveau

pip install bluepyopt 
+0

Merci pour votre commentaire! J'ai installé Microsoft Visual C++ Redistributable pour Visual Studio 2017, qui n'a rien changé. –

+1

N'installez pas l'outil de création Visual Studio, installez les outils de construction Visual C++ 2015 –

+0

Cela a résolu le problème pour mon noyau python 3! Agréable. Mais si je l'installe dans mon noyau python 2.7, j'obtiens la même sortie et l'erreur d'importation. Bizarre. –