简体   繁体   English

python命令行和jupyter笔记本之间的区别

[英]Difference between python command line and jupyter notebook

I have completed an installation of libfreenect package python wrapper by using the setup.py from here: https://github.com/OpenKinect/libfreenect/tree/master/wrappers/python 我已经通过使用setup.py从这里完成了libfreenect软件包python包装器的安装: https : //github.com/OpenKinect/libfreenect/tree/master/wrappers/python

I ran setup.py from within conda environment, but the corresponding ipython kernel cannot import it. 我在conda环境中运行setup.py,但相应的ipython内核无法导入它。 Upon importing, it says that the module cannot be found. 导入时,它说找不到模块。 When checking executable and path, I get the following: 检查可执行文件和路径时,得到以下信息:

import sys
print(sys.executable) 
print(sys.path)

/anaconda3/envs/p3.5/bin/python
['', '/anaconda3/envs/p3.5/lib/python35.zip', '/anaconda3/envs/p3.5/lib/python3.5', '/anaconda3/envs/p3.5/lib/python3.5/plat-darwin', '/anaconda3/envs/p3.5/lib/python3.5/lib-dynload', '/anaconda3/envs/p3.5/lib/python3.5/site-packages', '/anaconda3/envs/p3.5/lib/python3.5/site-packages/IPython/extensions', '/Users/ognjenmilicevic/.ipython']

But from the command line I get no error: 但是从命令行我没有任何错误:

/anaconda3/envs/p3.5/bin/python -c "import freenect"

How is this possible? 这怎么可能? What am I doing wrong? 我究竟做错了什么?

EDIT: After opening another terminal tab, "import freenect" fails however I call it, in conda environments or the main one. 编辑:打开另一个终端选项卡后,“导入freenect”失败,但是我在conda环境或主要环境中称它为“导入freenect”。 The command still works in the previous tab. 该命令在上一个选项卡中仍然有效。 I am even more confused now. 我现在更加困惑。

I apologize, it turns out the setup.py created .so file win the current folder, so import only works in that folder. 抱歉,事实证明setup.py创建的.so文件赢得了当前文件夹,因此导入仅在该文件夹中有效。 I didn't know this is possible, so I didn't take it into account. 我不知道这是可能的,所以我没有考虑到它。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM