I can't use matplotlib. I installed it with pip and it shows up in the pip list, but when I try to import it it says the module is not there. Others work, like pygame and I didn't do anything different when installing.
C:\Users\Torben>pip install matplotlib
Collecting matplotlib
Using cached matplotlib-3.4.2-cp39-cp39-win_amd64.whl (7.1 MB)
Requirement already satisfied: kiwisolver>=1.0.1 in c:\users\torben\appdata\local\programs\python\python39\lib\site-packages (from matplotlib) (1.3.1)
Requirement already satisfied: numpy>=1.16 in c:\users\torben\appdata\local\programs\python\python39\lib\site-packages (from matplotlib) (1.21.0)
Requirement already satisfied: cycler>=0.10 in c:\users\torben\appdata\local\programs\python\python39\lib\site-packages (from matplotlib) (0.10.0)
Requirement already satisfied: pillow>=6.2.0 in c:\users\torben\appdata\local\programs\python\python39\lib\site-packages (from matplotlib) (8.3.0)
Requirement already satisfied: python-dateutil>=2.7 in c:\users\torben\appdata\local\programs\python\python39\lib\site-packages (from matplotlib) (2.8.1)
Requirement already satisfied: pyparsing>=2.2.1 in c:\users\torben\appdata\local\programs\python\python39\lib\site-packages (from matplotlib) (2.4.7)
Requirement already satisfied: six in c:\users\torben\appdata\local\programs\python\python39\lib\site-packages (from cycler>=0.10->matplotlib) (1.16.0)
Installing collected packages: matplotlib
Successfully installed matplotlib-3.4.2
C:\Users\Torben>pip list
Package Version
cycler 0.10.0
kiwisolver 1.3.1
matplotlib 3.4.2
numpy 1.21.0
Pillow 8.3.0
pip 21.1.3
pygame 2.0.1
pyparsing 2.4.7
python-dateutil 2.8.1
setuptools 56.0.0
six 1.16.0
C:\Users\Torben>python
Python 3.9.6 (tags/v3.9.6:db3ff76, Jun 28 2021, 15:26:21) [MSC v.1929 64 bit (AMD64)] on win32
Type "help", "copyright", "credits" or "license" for more information.
import matplotlib
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "C:\Users\Torben\AppData\Local\Programs\Python\Python39\lib\site-packages\matplotlib\__init__.py", line 107, in <module>
from . import _api, cbook, docstring, rcsetup
File "C:\Users\Torben\AppData\Local\Programs\Python\Python39\lib\site-packages\matplotlib\rcsetup.py", line 24, in <module>
from matplotlib import _api, animation, cbook
File "C:\Users\Torben\AppData\Local\Programs\Python\Python39\lib\site-packages\matplotlib\animation.py", line 34, in <module>
from PIL import Image
File "C:\Users\Torben\AppData\Local\Programs\Python\Python39\lib\site-packages\PIL\Image.py", line 114, in <module>
from . import _imaging as core
ImportError: DLL load failed while importing _imaging: Das angegebene Modul wurde nicht gefunden.`][1]
(last line -> DLL load failed while importing _imaging: The specified module was not found.)
Probably the C++ runtime library is not installed in your machine or environment. Try python -m pip install msvc-runtime
Related
I'm running the latest Kali Linux with Python 3.7 and am trying to use the requests module. As you can see, I install requests but still cannot import it. Could someone help me reconcile this strange problem?
root#kali:~/Desktop# pip3 install --upgrade requests
Requirement already up-to-date: requests in
/usr/local/lib/python3.7/site-packages (2.20.1)
Requirement already satisfied, skipping upgrade: urllib3<1.25,>=1.21.1
in /usr/local/lib/python3.7/site-packages (from requests) (1.23)
Requirement already satisfied, skipping upgrade: chardet<3.1.0,>=3.0.2 in /usr/local/lib/python3.7/site-packages (from requests) (3.0.4)
Requirement already satisfied, skipping upgrade: certifi>=2017.4.17 in /usr/local/lib/python3.7/site-packages (from requests) (2018.10.15)
Requirement already satisfied, skipping upgrade: idna<2.8,>=2.5 in /usr/local/lib/python3.7/site-packages (from requests) (2.7)
root#kali:~/Desktop# python3
Python 3.5.6 (default, Sep 29 2018, 21:41:04)
[GCC 8.2.0] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import requests
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
ImportError: No module named 'requests'
Thanks ahead of time for the help!
Since it appears you have multiple versions of Python installed you'll need to set your environment to use Python 3.7 (currently it's set to 3.5.6, and requests doesn't appear to be installed).
In your .bash_profile you could probably do:
alias python3=/path/to/python3.7
which should use the 3.7 version when you enter python3 ...
I have installed anaconda on my mac os. But when I am trying to import panda library, It is throwing error as panda module not found.
So when I again try to install panda. It says panda already installed on machine
C27:python-programming jyoti.aditya$ pip install pandas
Requirement already satisfied: pandas in
/Users/aditya/anaconda3/lib/python3.7/site-packages (0.23.4)
Requirement already satisfied: python-dateutil>=2.5.0 in
/Users/aditya/anaconda3/lib/python3.7/site-packages (from pandas)
(2.7.3)
Requirement already satisfied: pytz>=2011k in
/Users/aditya/anaconda3/lib/python3.7/site-packages (from pandas)
(2018.5)
Requirement already satisfied: numpy>=1.9.0 in
/Users/aditya/anaconda3/lib/python3.7/site-packages (from pandas)
(1.15.1)
Requirement already satisfied: six>=1.5 in
/Users/aditya/anaconda3/lib/python3.7/site-packages (from python-
dateutil>=2.5.0->pandas) (1.11.0)
But when I try to import Panda library in my python code. It throws error
C27:python-programming aditya$ python
Python 3.7.0 (default, Jun 28 2018, 07:39:16)
[Clang 4.0.1 (tags/RELEASE_401/final)] :: Anaconda, Inc. on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>>
>>> import panda as pd
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
ModuleNotFoundError: No module named 'panda'
The module name is pandas, not panda. Customarily it is imported like this:
import pandas as pd
See the 10 Minutes to pandas page for a quick introduction to the library.
You have installed pandas via pip but when trying to import it you have missed the s off the end of pandas.
import pandas as pd will work.
This question already has an answer here:
ImportError: No module named flaskext.sqlalchemy
(1 answer)
Closed 4 years ago.
Why the following?
from flask import Flask
from flask.ext.bcrypt import Bcrypt
Python 2.7.12 (default, Dec 4 2017, 14:50:18)
[GCC 5.4.0 20160609] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> from flask import Flask
>>> from flask.ext.bcrypt import Bcrypt
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
ImportError: No module named ext.bcrypt
I have flask-bcrypt installed:
pip install Flask-Bcrypt
Requirement already satisfied: Flask-Bcrypt in /usr/local/lib/python2.7/dist-packages (0.7.1)
Requirement already satisfied: Flask in /usr/local/lib/python2.7/dist-packages (from Flask-Bcrypt) (1.0.2)
Requirement already satisfied: bcrypt in /usr/local/lib/python2.7/dist-packages/bcrypt-3.1.4-py2.7-linux-x86_64.egg (from Flask-Bcrypt) (3.1.4)
Requirement already satisfied: Jinja2>=2.10 in /usr/local/lib/python2.7/dist-packages/Jinja2-2.10-py2.7.egg (from Flask->Flask-Bcrypt) (2.10)
Requirement already satisfied: itsdangerous>=0.24 in /usr/local/lib/python2.7/dist-packages (from Flask->Flask-Bcrypt) (0.24)
Requirement already satisfied: Werkzeug>=0.14 in /usr/local/lib/python2.7/dist-packages (from Flask->Flask-Bcrypt) (0.14.1)
Requirement already satisfied: click>=5.1 in /usr/local/lib/python2.7/dist-packages (from Flask->Flask-Bcrypt) (6.7)
Requirement already satisfied: cffi>=1.1 in /usr/local/lib/python2.7/dist-packages/cffi-1.11.5-py2.7-linux-x86_64.egg (from bcrypt->Flask-Bcrypt) (1.11.5)
Requirement already satisfied: six>=1.4.1 in /usr/local/lib/python2.7/dist-packages/six-1.10.0-py2.7.egg (from bcrypt->Flask-Bcrypt) (1.10.0)
Requirement already satisfied: MarkupSafe>=0.23 in /usr/local/lib/python2.7/dist-packages/MarkupSafe-1.0-py2.7-linux-x86_64.egg (from Jinja2>=2.10->Flask->Flask-Bcrypt) (1.0)
Requirement already satisfied: pycparser in /usr/local/lib/python2.7/dist-packages/pycparser-2.18-py2.7.egg (from cffi>=1.1->bcrypt->Flask-Bcrypt) (2.18)
This error leaves me nowhere to go. I followed the docs here:
https://flask-bcrypt.readthedocs.io/en/latest/
Try using from flask_bcrypt import Bcrypt.
This is because the flask documentation on flask extensions implies that extensions in the form of Flask-Foo and are imported as: from flask_foo import Foo
http://flask.pocoo.org/docs/1.0/extensions/
In the recent flask's update, from flask.ext.xxx import xxx has been removed. You should import it directly from its package. And here is a related issue.
By the way, this package seems out of date(last updates two years ago).
I got the following error when I try to install tensorflow in linux.
I'd like to install tensorflow on linux. I prefer not to use virtualenv.
https://www.tensorflow.org/install/install_linux
Does anybody know what the correct sequence of commends is to install tensorflow? Thanks.
$ pip install --upgrade tensorflow
Requirement already up-to-date: tensorflow in /home/py/.linuxbrew/lib/python2.7/site-packages
Requirement already up-to-date: mock>=2.0.0 in /home/py/.linuxbrew/lib/python2.7/site-packages (from tensorflow)
Requirement already up-to-date: tensorflow-tensorboard<0.5.0,>=0.4.0rc1 in /home/py/.linuxbrew/lib/python2.7/site-packages (from tensorflow)
Requirement already up-to-date: backports.weakref>=1.0rc1 in /home/py/.linuxbrew/lib/python2.7/site-packages (from tensorflow)
Requirement already up-to-date: wheel in /home/py/.linuxbrew/lib/python2.7/site-packages (from tensorflow)
Requirement already up-to-date: numpy>=1.12.1 in /home/py/.linuxbrew/lib/python2.7/site-packages (from tensorflow)
Collecting protobuf>=3.3.0 (from tensorflow)
Using cached protobuf-3.5.1-py2.py3-none-any.whl
Requirement already up-to-date: six>=1.10.0 in /home/py/.linuxbrew/lib/python2.7/site-packages (from tensorflow)
Requirement already up-to-date: enum34>=1.1.6 in /home/py/.linuxbrew/lib/python2.7/site-packages (from tensorflow)
Requirement already up-to-date: funcsigs>=1; python_version < "3.3" in /home/py/.linuxbrew/lib/python2.7/site-packages (from mock>=2.0.0->tensorflow)
Requirement already up-to-date: pbr>=0.11 in /home/py/.linuxbrew/lib/python2.7/site-packages (from mock>=2.0.0->tensorflow)
Requirement already up-to-date: bleach==1.5.0 in /home/py/.linuxbrew/lib/python2.7/site-packages (from tensorflow-tensorboard<0.5.0,>=0.4.0rc1->tensorflow)
Requirement already up-to-date: futures>=3.1.1; python_version < "3.2" in /home/py/.linuxbrew/lib/python2.7/site-packages (from tensorflow-tensorboard<0.5.0,>=0.4.0rc1->tensorflow)
Collecting markdown>=2.6.8 (from tensorflow-tensorboard<0.5.0,>=0.4.0rc1->tensorflow)
Requirement already up-to-date: html5lib==0.9999999 in /home/py/.linuxbrew/lib/python2.7/site-packages (from tensorflow-tensorboard<0.5.0,>=0.4.0rc1->tensorflow)
Collecting werkzeug>=0.11.10 (from tensorflow-tensorboard<0.5.0,>=0.4.0rc1->tensorflow)
Using cached Werkzeug-0.13-py2.py3-none-any.whl
Collecting setuptools (from protobuf>=3.3.0->tensorflow)
Using cached setuptools-38.2.5-py2.py3-none-any.whl
Installing collected packages: setuptools, protobuf, markdown, werkzeug
Found existing installation: setuptools 38.2.4
Uninstalling setuptools-38.2.4:
Successfully uninstalled setuptools-38.2.4
Found existing installation: protobuf 3.5.0.post1
Uninstalling protobuf-3.5.0.post1:
Successfully uninstalled protobuf-3.5.0.post1
Found existing installation: Markdown 2.6.9
Uninstalling Markdown-2.6.9:
Successfully uninstalled Markdown-2.6.9
Found existing installation: Werkzeug 0.12.2
Uninstalling Werkzeug-0.12.2:
Successfully uninstalled Werkzeug-0.12.2
Successfully installed markdown-2.6.10 protobuf-3.5.1 setuptools-38.2.5 werkzeug-0.13
$ python
Python 2.7.12 (default, Feb 3 2017, 09:33:51)
[GCC 4.8.4] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> import tensorflow as tf
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/home/py/.linuxbrew/Cellar/python/2.7.12_3/lib/python2.7/site-packages/tensorflow/__init__.py", line 24, in <module>
from tensorflow.python import *
File "/home/py/.linuxbrew/Cellar/python/2.7.12_3/lib/python2.7/site-packages/tensorflow/python/__init__.py", line 49, in <module>
from tensorflow.python import pywrap_tensorflow
File "/home/py/.linuxbrew/Cellar/python/2.7.12_3/lib/python2.7/site-packages/tensorflow/python/pywrap_tensorflow.py", line 72, in <module>
raise ImportError(msg)
ImportError: Traceback (most recent call last):
File "/home/py/.linuxbrew/Cellar/python/2.7.12_3/lib/python2.7/site-packages/tensorflow/python/pywrap_tensorflow.py", line 58, in <module>
from tensorflow.python.pywrap_tensorflow_internal import *
File "/home/py/.linuxbrew/Cellar/python/2.7.12_3/lib/python2.7/site-packages/tensorflow/python/pywrap_tensorflow_internal.py", line 28, in <module>
_pywrap_tensorflow_internal = swig_import_helper()
File "/home/py/.linuxbrew/Cellar/python/2.7.12_3/lib/python2.7/site-packages/tensorflow/python/pywrap_tensorflow_internal.py", line 24, in swig_import_helper
_mod = imp.load_module('_pywrap_tensorflow_internal', fp, pathname, description)
ImportError: /home/py/.linuxbrew/Cellar/python/2.7.12_3/lib/python2.7/site-packages/tensorflow/python/_pywrap_tensorflow_internal.so: invalid ELF header
Failed to load the native TensorFlow runtime.
See https://www.tensorflow.org/install/install_sources#common_installation_problems
for some common reasons and solutions. Include the entire stack trace
above this error message when asking for help.
>>>
Any idea how this could be fixed?
mona#pascal:~$ 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
mona#pascal:~$ source /usr/local/bin/virtualenvwrapper.sh
mona#pascal:~$ workon cv2
(cv2) mona#pascal:~$ 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) mona#pascal:~/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) mona#pascal:~/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) mona#pascal:~/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) mona#pascal:~/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'
The problem is that you are running pip with sudo from the virtualenv. This temporarily makes you root, resets all the environment variables that are set by virtualenvwrapper and thus installs the packages system-wide instead in the virtualenv.
This should work better:
workon cv2
pip install keras tensorflow
Is it possible when creating cv2 environment, you did not create it with --system-site-packages flag?
If not, you can always pip install keras inside the virtualenv.