我正在使用Jupyter Notebook,我想導入名爲bluepyopt的外部工具箱。由於它目前只在Python 2.7中運行,因此我按照here的描述設置了一個Python 2.7內核。所以我可以在Jupyter Notebook中將內核更改爲python 2。 如果我想導入使用Python:成功安裝模塊,但無法通過導入獲得
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筆記本使用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
[錯誤的可能的複製,同時通過PIP安裝lxml的安裝模塊:微軟的Visual C++ 14.0需要](https://stackoverflow.com/questions/38949519/error-while-installing-lxml-through-pip-microsoft-visual-c-14-0-is-required) – phd