我在OSX el Capitan上做数据科学。为此,我使用了anaconda和Python2.7
我成功地使用了各种env,总的来说,我对anaconda非常满意。
现在我想做一个新的env ( tf for tensorflow)并安装opencv 3.1,我在几次尝试后成功了。所以,如果我打开python,它会提示
Python 2.7.13 |Continuum Analytics, Inc.| (default, Dec 20 2016, 23:05:08)
[GCC 4.2.1 Compatible Apple LLVM 6.0 (clang-600.0.57)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
Anaconda is brought to you by Continuum Analytics.
Please check out: http://continuum.io/thanks and https://anaconda.org然后我就这么做了
import cv2
print(cv2.__version__)它会提示我3.1.0版本
到目前一切尚好。
所有这些我都是在我的环境中完成的
但现在我把笔记本命名为
jupyter notebook并打开一个新的笔记本,导入cv2,它不像这样
ImportError: No module named cv2我无法理解这一点,需要帮助!
当我
conda list我得到了所有的包(见下面的部分粘贴)
jsonschema 2.5.1 py27_0
jupyter 1.0.0 py27_3
jupyter_client 5.0.0 py27_0
jupyter_console 5.1.0 py27_0
jupyter_core 4.3.0 py27_0
libpng 1.6.28 0 conda-forge
libtiff 4.0.6 7 conda-forge
markupsafe 0.23 py27_2
mistune 0.7.4 py27_0
mkl 2017.0.1 0
nbconvert 5.1.1 py27_0
nbformat 4.3.0 py27_0
notebook 4.4.1 py27_0
numpy 1.12.0 py27_0
opencv 3.1.0 np112py27_1 conda-forge
opencv3 3.1.0 py27_0 menpo
openssl 1.0.2k 当我这样做时,我还添加了系统的输出作为信息
conda info -a我得到了
Current conda install:
platform : osx-64
conda version : 4.3.14
conda is private : False
conda-env version : 4.3.14
conda-build version : not installed
python version : 2.7.13.final.0
requests version : 2.12.4
root environment : /Users/peterhirt/anaconda (writable)
default environment : /Users/peterhirt/anaconda/envs/tf
envs directories : /Users/peterhirt/anaconda/envs
/Users/peterhirt/.conda/envs
package cache : /Users/peterhirt/anaconda/pkgs
/Users/peterhirt/.conda/pkgs
channel URLs : https://repo.continuum.io/pkgs/free/osx-64
https://repo.continuum.io/pkgs/free/noarch
https://repo.continuum.io/pkgs/r/osx-64
https://repo.continuum.io/pkgs/r/noarch
https://repo.continuum.io/pkgs/pro/osx-64
https://repo.continuum.io/pkgs/pro/noarch
config file : None
offline mode : False
user-agent : conda/4.3.14 requests/2.12.4 CPython/2.7.13 Darwin/15.6.0 OSX/10.11.6
UID:GID : 501:20
# conda environments:
#
tf * /Users/peterhirt/anaconda/envs/tf
root /Users/peterhirt/anaconda
sys.version: 2.7.13 |Anaconda 4.3.1 (x86_64)| (defaul...
sys.prefix: /Users/peterhirt/anaconda
sys.executable: /Users/peterhirt/anaconda/bin/python
conda location: /Users/peterhirt/anaconda/lib/python2.7/site-packages/conda
conda-build: None
conda-env: /Users/peterhirt/anaconda/bin/conda-env
conda-server: /Users/peterhirt/anaconda/bin/conda-server
user site dirs: ~/.local/lib/python2.7
CIO_TEST: <not set>
CONDA_DEFAULT_ENV: tf
CONDA_ENVS_PATH: <not set>
DYLD_LIBRARY_PATH: <not set>
PATH: /Users/peterhirt/anaconda/envs/tf/bin:/Users/peterhirt/anaconda/bin:/usr/local/bin:/Users/peterhirt/.npm-packages/bin:/Users/peterhirt/anaconda2/bin:/Users/peterhirt/google-cloud-sdk/bin:/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin
PYTHONHOME: <not set>
PYTHONPATH: <not set>
License directories:
/Users/peterhirt/.continuum
/Users/peterhirt/Library/Application Support/Anaconda
/Users/peterhirt/anaconda/licenses
License files (license*.txt):
Package/feature end dates:发布于 2017-09-20 14:35:42
在这种情况下,使用Docker镜像最好,因为它封装了环境。您可以从here安装Docker。
在拉取图像之后,您可以在shell中使用如下代码:
docker run --rm -it -p 8888:8888 -v d:/Kaggles:/d datmo/kaggle:cpu在容器中运行jupyter notebook
jupyter notebook --ip=0.0.0.0 --no-browser这会将本地目录挂载到有权访问它的容器上。
然后,转到浏览器并点击https://localhost:8888,当我打开一个新内核时,它是Python3.5。
你可以在here上找到更多信息。
您还可以尝试使用datmo,以便轻松设置环境和跟踪机器学习项目,从而使实验具有可重复性。您可以运行datmo task命令来设置jupyter笔记本,如下所示:
datmo任务运行'jupyter notebook‘--端口8888
它在环境中设置您的项目和文件,以跟踪您的进度。
https://stackoverflow.com/questions/42885153
复制相似问题