Python:成功安装模块,但无法通过导入获得
我正在使用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
我所看到的模块安装不正确,并为Microsoft Visual C++ 14.0给人的依赖。
尝试安装Microsoft的Visual C++从这个链接构建工具http://landinghub.visualstudio.com/visual-cpp-build-tools
然后尝试使用PIP再次
pip install bluepyopt
感谢您的评论!我在Visual Studio 2017中安装了Microsoft Visual C++可再发行版,该版本没有任何改变。 –
不要安装visual studio构建工具,安装visual C++ 2015构建工具 –
这解决了我的python 3内核的问题!尼斯。但是,如果我将它安装在我的python 2.7内核中,我会得到相同的输出和导入错误。奇怪的。 –
[错误的可能的复制,同时通过PIP安装lxml的安装模块:微软的Visual C++ 14.0需要](https://*.com/questions/38949519/error-while-installing-lxml-through-pip-microsoft-visual-c-14-0-is-required) – phd