2017-01-19 2 views
0

어떻게 수정 될 수 있었는지 생각해보십시오.가상 환경에서 Keras를 가져올 수 없음

[email protected]:~$ python3 
Python 3.4.3 (default, Nov 17 2016, 01:08:31) 
[GCC 4.8.4] on linux 
Type "help", "copyright", "credits" or "license" for more information. 
>>> import keras 
Using TensorFlow backend. 
I tensorflow/stream_executor/dso_loader.cc:128] successfully opened CUDA library libcublas.so locally 
I tensorflow/stream_executor/dso_loader.cc:128] successfully opened CUDA library libcudnn.so locally 
I tensorflow/stream_executor/dso_loader.cc:128] successfully opened CUDA library libcufft.so locally 
I tensorflow/stream_executor/dso_loader.cc:128] successfully opened CUDA library libcuda.so.1 locally 
I tensorflow/stream_executor/dso_loader.cc:128] successfully opened CUDA library libcurand.so locally 
[email protected]:~$ source /usr/local/bin/virtualenvwrapper.sh 
[email protected]:~$ workon cv2 
(cv2) [email protected]:~$ python 
Python 3.4.3 (default, Nov 17 2016, 01:08:31) 
[GCC 4.8.4] on linux 
Type "help", "copyright", "credits" or "license" for more information. 
>>> import keras 
Traceback (most recent call last): 
    File "<stdin>", line 1, in <module> 
ImportError: No module named 'keras' 

UPDATE :

$ sudo pip install keras 
The directory '/home/mona/.cache/pip/http' or its parent directory is not owned by the current user and the cache has been disabled. Please check the permissions and owner of that directory. If executing pip with sudo, you may want sudo's -H flag. 
The directory '/home/mona/.cache/pip' or its parent directory is not owned by the current user and caching wheels has been disabled. check the permissions and owner of that directory. If executing pip with sudo, you may want sudo's -H flag. 
Collecting keras 
/usr/local/lib/python2.7/dist-packages/pip/_vendor/requests/packages/urllib3/util/ssl_.py:318: SNIMissingWarning: An HTTPS request has been made, but the SNI (Subject Name Indication) extension to TLS is not available on this platform. This may cause the server to present an incorrect TLS certificate, which can cause validation failures. You can upgrade to a newer version of Python to solve this. For more information, see https://urllib3.readthedocs.io/en/latest/security.html#snimissingwarning. 
    SNIMissingWarning 
/usr/local/lib/python2.7/dist-packages/pip/_vendor/requests/packages/urllib3/util/ssl_.py:122: InsecurePlatformWarning: A true SSLContext object is not available. This prevents urllib3 from configuring SSL appropriately and may cause certain SSL connections to fail. You can upgrade to a newer version of Python to solve this. For more information, see https://urllib3.readthedocs.io/en/latest/security.html#insecureplatformwarning. 
    InsecurePlatformWarning 
    Downloading Keras-1.2.0.tar.gz (167kB) 
    100% |████████████████████████████████| 174kB 2.1MB/s 
Collecting theano (from keras) 
    Downloading Theano-0.8.2.tar.gz (2.9MB) 
    100% |████████████████████████████████| 2.9MB 346kB/s 
Requirement already satisfied: pyyaml in /usr/lib/python2.7/dist-packages (from keras) 
Requirement already satisfied: six in /usr/local/lib/python2.7/dist-packages (from keras) 
Requirement already satisfied: numpy>=1.7.1 in /usr/local/lib/python2.7/dist-packages (from theano->keras) 
Requirement already satisfied: scipy>=0.11 in /usr/lib/python2.7/dist-packages (from theano->keras) 
Installing collected packages: theano, keras 
    Running setup.py install for theano ... done 
    Running setup.py install for keras ... done 
Successfully installed keras-1.2.0 theano-0.8.2 
(cv2) [email protected]:~/computer_vision/opencv-3.2.0/build$ python 
Python 3.4.3 (default, Nov 17 2016, 01:08:31) 
[GCC 4.8.4] on linux 
Type "help", "copyright", "credits" or "license" for more information. 
>>> import keras 
Traceback (most recent call last): 
    File "<stdin>", line 1, in <module> 
ImportError: No module named 'keras' 

(cv2) [email protected]:~/computer_vision/opencv-3.2.0/build$ sudo pip3 install keras 
Requirement already satisfied (use --upgrade to upgrade): keras in /usr/local/lib/python3.4/dist-packages 
Requirement already satisfied (use --upgrade to upgrade): theano in /usr/local/lib/python3.4/dist-packages (from keras) 
Requirement already satisfied (use --upgrade to upgrade): pyyaml in /usr/local/lib/python3.4/dist-packages (from keras) 
Requirement already satisfied (use --upgrade to upgrade): six in /usr/local/lib/python3.4/dist-packages (from keras) 
Requirement already satisfied (use --upgrade to upgrade): numpy>=1.7.1 in /usr/local/lib/python3.4/dist-packages (from theano->keras) 
Requirement already satisfied (use --upgrade to upgrade): scipy>=0.11 in /usr/local/lib/python3.4/dist-packages (from theano->keras) 
Cleaning up... 
(cv2) [email protected]:~/computer_vision/opencv-3.2.0/build$ sudo pip3 install --upgrade keras 
Requirement already up-to-date: keras in /usr/local/lib/python3.4/dist-packages 
Requirement already up-to-date: theano in /usr/local/lib/python3.4/dist-packages (from keras) 
Requirement already up-to-date: pyyaml in /usr/local/lib/python3.4/dist-packages (from keras) 
Requirement already up-to-date: six in /usr/local/lib/python3.4/dist-packages (from keras) 
Requirement already up-to-date: numpy>=1.7.1 in /usr/local/lib/python3.4/dist-packages (from theano->keras) 
Requirement already up-to-date: scipy>=0.11 in /usr/local/lib/python3.4/dist-packages (from theano->keras) 
Cleaning up... 
(cv2) [email protected]:~/computer_vision/opencv-3.2.0/build$ python 
Python 3.4.3 (default, Nov 17 2016, 01:08:31) 
[GCC 4.8.4] on linux 
Type "help", "copyright", "credits" or "license" for more information. 
>>> import keras 
Traceback (most recent call last): 
    File "<stdin>", line 1, in <module> 
ImportError: No module named 'keras' 
+0

당신은'내부와 외부의 VIRTUALENV의 freeze' 핍의 출력을 게시 할 수 있을까요? –

답변

-1

cv2 환경을 만들 때 가능하면 --system-site-packages 플래그를 생성하지 않는 이유는 무엇입니까? 그렇지 않은 경우 virtualenv 내에 항상 pip install keras을 사용할 수 있습니다.

+0

업데이트를 참조하십시오. 불행히도 그것은 작동하지 않았다! –

+0

가상 시스템을'--system-site-package'와 함께 사용하면 그 목적이 무효가됩니다. –

+0

@HaraldNordgren'--system-site-packages'는 시스템에 설치된 패키지를 사용할 수있게하지만 여전히 환경에 새 패키지를 설치할 수 있습니다. 이는 numpy를 시스템 전체에 한 번 설치하고 numpy에 의존하는 다른 패키지를 신속하게 반복하려는 경우에 유용합니다. @mona-jalal 업데이트는 여전히 가상 환경을 만든 방법을 보여주지 않습니다. 그러나 @ HaraldNordgren의 제안은 효과가있다. 그러나 sudo를 처음 시도한 이후로는 더 이상 재기록 할 수없는 파일이있을 수 있으므로 새로운 환경 (cv3 어쩌면)을 만들고 거기에서 시도해 보는 것이 좋습니다. – gunan

1

pipsudo이 virtualenv에서 실행 중입니다. 이렇게하면 임시로 루트가 만들어지고 virtualenvwrapper에 의해 설정된 모든 환경 변수가 재설정되므로 virtualenv 대신 시스템 전체에 패키지가 설치됩니다.

이 잘 작동해야합니다

workon cv2 
pip install keras tensorflow