I am attempting to teach myself programming and keep running into problems downloading modules I need for basic tutorials.
My latest attempt has been to get the matplotlib module into my Python 3 environment. I have tried so many different install packages and so many advice I found on the internet that I cannot remember how I originally got the module. But it seemed that everything went well with the installation process.
I am using a Raspberry Pi2 throughout all of this with the Raspbian OS installed.
Python 3.2.3 (default, Mar 1 2013, 11:53:50)
[GCC 4.6.3] on linux2
Type "copyright", "credits" or "license()" for more information.
>>> import matplotlib
Traceback (most recent call last):
File "<pyshell#0>", line 1, in <module>
import matplotlib
ImportError: No module named matplotlib
It may be possible that you actually installed the library for python 2. I would use pip to install the modules that you need. If you don't already have it installed, run this first command in the shell:
sudo apt-get install python3-pip
This program can be called with "pip3" or maybe "pip-3.2" in the shell.
To install mathplotlib with it, try running:
pip3 install matplotlib
or
pip-3.2 install matplotlib
That should install the Python 3 module for you.
Related
When I try to use
import praw
I get the following error:
ModuleNotFoundError: No module named 'praw'
I made sure to install praw beforehand in the command prompt, using pip install praw, so I'm not sure why it isn't working. I'm new to programming, so any insight would be greatly appreciated.
It depends on the python version (yours say Python3.9) in your environment.
Try pip3 to install your packages.
I would open up the terminal and do the following:
$ pip3 install praw
$ python3 myscript.py
I had the same problem and was looking into several ways to solve it.
For me the solution was as simple as changing the name of the pyhton file to some like "test" instead of "praw".
Yes, I named my file "praw.py" and was importing praw which was the origin of the error.
You could very well be having an issue with multiple python installations across your system. I suggest cleaning up your environment, and using a virtual environment.
You should run the following to build a clean virtual environment in your working directory:
python -m venv venv
This will create a virtual environment which should be free of system-wide packages, and is a nice and shiny clean python installation.
Now you'll want to activate it. You said you were on Windows, so then run
venv\Scripts\activate.bat if you're using CMD, or venv\Scripts\Activate.ps1 if you're using PowerShell.
Now try reinstalling praw with python -m pip install praw. You should now always be able to access praw if you're in this virtual environment.
If you're interested on reading the documentation on VirtualEnvs, here it is. You might also be interested in checking out the Hitchhiker's Guide to Python, especially the chapter on virtual environments and package management. (Do note that this last chapter uses pipenv instead of virtualenv.)
I've installed praw using pip3 install praw. So it is not showing in my system default python i.e python 2.7.17.
cam#cam:~$ python
Python 2.7.17 (default, Sep 30 2020, 13:38:04)
[GCC 7.5.0] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> import praw
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
ImportError: No module named praw
>>>
[5]+ Stopped python
cam#cam:~$ python3
Python 3.6.9 (default, Oct 8 2020, 12:12:24)
[GCC 8.4.0] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import praw
If you want to use praw with python2 you'll have to use:
pip install praw
If you want to use praw with python3 you'll have to use:
pip3 install praw
Thank you all so much for your help, but I have finally figured out what was causing my problem! In a separate file for the bot called requirements.txt, I had:
git+https://github.com/Rapptz/Discord.py
PyNaCl==1.3.0
pandas
dnspython==1.16.0
async-timeout==3.0.1
I simply added praw==7.2.0, and it worked! I appreciate your efforts in trying to help me :)
Note - I already check numpy import error related threads but none helped
I am using debian 8 where default python is 2.7.9. I installed python 3.4.2 and created virutal env.
Within virtual environment -
python -V
Python 3.4.2
pip -V
pip 1.5.6 from /path/venv34/lib/python3.4/site-packages (python 3.4)
I have python3 numpy package - python3-numpy_1.12.0-2~pn0_amd64.deb
which I have installed with sudo dpkg -i python3-numpy_1.12.0-2~pn0_amd64.deb
which successfully completed.
Now when I do
python
Python 3.4.2 (default, Feb 7 2019, 06:08:06)
[GCC 4.9.2] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import numpy
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
ImportError: No module named 'numpy'
>>>
Any clue what's wrong here?
python3.4 -m pip install numpy==1.12.0-2
ok since my repo is less than 50 i can not add comments, so take this answer as a comment to your question.
I think numpy is installed but not in your virtualenv, make sure your virtualenv is active when you are trying to install any library, you will see virtualenv name in every command line if it is activated.
(venv) C:\Users\seventeen\sprint25>
Try python -m pip install numpy==1.12.0. This should help you.
I have two python 3 locations. One is located here,
"C:\Users\Ryano\AppData\Local\Programs\Python\Python37-32"
The other is related to Anaconda3 here,
"C:\Users\Ryano\Anaconda3"
I want run a .py file that uses the numpy package in the command prompt using the Anaconda3 python version. I go to import numpy and it doesn't recognize it:
C:\Users\Ryano\Anaconda3>python
Python 3.7.1 (default, Oct 28 2018, 08:39:03) [MSC v.1912 64 bit (AMD64)] :: Anaconda, Inc. on win32
Type "help", "copyright", "credits" or "license" for more information.
import numpy
Traceback (most recent call last):
File "", line 1, in
ModuleNotFoundError: No module named 'numpy'
So I go to install the numpy package to the Anaconda 3 version python and this error pops up:
C:\Users\Ryano\Anaconda3\Scripts>pip install numpy
Collecting numpy
Using cached https://files.pythonhosted.org/packages/00/0e/5a8c34adb97fc1cd6636d78050e575945e874c8516d501421d5a0f377a6c/numpy-1.15.4-cp37-none-win_amd64.whl
Could not install packages due to an EnvironmentError: [Errno 2] No such file or directory: 'c:\users\ryano\anaconda3\lib\site-packages\html5lib-1.0.1.dist-info\METADATA'
Looking at the other posts similar to this one I could not find any solution that worked for my computer. Essentially I'm having issues with installing using pip.
Reinstall html5lib with conda:
conda install html5lib
There can be issues with using multiple installations on Windows.
Please check the answer to this question: what is the process of installing and working with PIL - Python Imaging Library ?
Hopefully one of the questions will fix the issue. If not, let me know.
I have python-2.7.9 installed on my machine and I am trying to install numpy, matplotlib, pyopengl, and pyqt4.
I've installed pyqt4 using the source file and it imports fine when using python, however, i get an error for the remaining packages.... no module named numpy.
I installed numpy and matplotlib using the following commands:
sudo apt-get install python-numpy
sudo apt-get install pyhton-matplotlib
I also tried using pip and aptitude but I still get the same error..im not sure what I am doing wrong or how to fix these issues. Does anyone have any advice?
UPDATE:
Using Ubuntu 14.04.1 LTS
These are the errors I get:
Python 2.7.9 (default, Feb 5 2015, 11:24:57)
[GCC 4.8.2] on linux2
Type "help", "copyright", or "license" for more information.
import numpy
Traceback (most recent call last):
File "", line 1, in
ImportError: Mo module named numpy
In ubuntu 14.04, the packages you want are not called simply numpy and matplotlib. Instead they are python-numpy and python-matplotlib. Thus to install them you need:
sudo apt-get install python-numpy
sudo apt-get install python-matplotlib
EDIT:
Based on the comments below, the issue was a different version of python 2.7than the one provided by Ubuntu. More info in comments. An alias to the ubuntu's python seems to solved the problem.
I'm trying to use OpenCV from within Python on an system using Ubuntu 14.04. When I try to import cv2, I get the following error:
me#Bedrock1:~$ python
Python 2.7.6 (default, Mar 22 2014, 22:59:56)
[GCC 4.8.2] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> import cv2
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
ImportError: libavcodec.so.53: cannot open shared object file: No such file or directory
A search for libavcodec.so.53 reveals that my system has only libavcodec.so.54.
A search of the internet reveals that libavcodec.so.53 has been removed from the 14.04 repository (http://www.ubuntuupdates.org/package/core/trusty/universe/base/libavcodec53). This, probably, explains my inability to apt-get install this library:
me#Bedrock1:~$ sudo apt-get install libavcodec53 libavcodec-extra-53
...
E: Package 'libavcodec53' has no installation candidate
E: Package 'libavcodec-extra-53' has no installation candidate
Unfortunately, now I'm truly stuck.
Is there a way to get the cv2 module to use libavcodec.so.54, or a way to find & install libavcodec.so.53?
NOTE: I just tried reinstalling by following the instructions at https://help.ubuntu.com/community/OpenCV
but I still am getting the same libavcodec.so.53 error....
Try this script. Ubuntu man page has an old version of this script. This should work.
https://github.com/jayrambhia/Install-OpenCV/blob/master/Ubuntu/2.4/opencv2_4_9.sh
Check if reinstalling opencv resolves the issue
sudo apt-get install --reinstall python-opencv
BTW how did you install it before ?
I got the same problem on Ubuntu 14.04 64bit, as reported here:
https://bugs.launchpad.net/ubuntu/+source/opencv/+bug/1161485/comments/2
I tried downloading the source package and recompiling, in order to get the correct libraries linked, but with no luck.
At the end, I recompiled from source, following these instructions:
http://docs.opencv.org/doc/tutorials/introduction/linux_install/linux_install.html
Everything goes fine except for the python module compilation, which was disable at configure time (listed in Opencv modules: Unavailable: section).
I used cmake-gui to configure the build and generate makefiles. The configuration step was correctly setting PYTHON2_INCLUDE_DIR, PYTHON2_INCLUDE_DIR2 and PYTHON2_LIBRARY, but it was NOT setting PYTHON_INCLUDE_DIR, PYTHON_INCLUDE_DIR2 and PYTHON_LIBRARY.
In order to actually build the python module, you should set these PYTHON_ variables equal to their corresponding PYTHON2_ variables. Then, the make step will build also cv2.so.