Installation of pyplot for python 3.5.2 - python-3.x

I am trying to import the following statements. My end goal is to generate a word cloud.
I am using enathught canopy python 3.5.2 In the terminal prompt from canopy I ran the command below:
import matplotlib.pyplot as plt
from wordcloud import WordCloud, STOPWORDS
which returned no module names 'pyQt4'
So i tried installing that !pip install 'pyQt4'
output obtained:
Collecting pyqt4
Could not find a version that satisfies the requirement pyqt4 (from versions: )
No matching distribution found for pyqt4
Also I tried !pip install pyplot which again gave the same errorno module names 'pyQt4'
Please help as to what I can do from command prompt?

You need to install pyQt4. If you are using Anaconda, pyQt5 is included. For some package, they require pyQt4. It took me a long time trying to install pyQt4. My solution is download pyQt4 from http://www.lfd.uci.edu/~gohlke/pythonlibs/#pyqt4, and install the .whl file with:
pip install some-package.whl

Related

When try to run import pandas from Visual Studio Code it thrown an ImportError, but works fine in Anaconda (Jupyter Notebook)

I used to code in Jupyter notebook and importing pandas was never thrown an error. But when I use the same code in Visual Studio Code,
# Import Libraries
from random import seed
from random import randint
import pandas
import numpy
import math
import random
import collections
import itertools
import collections
import matplotlib.pyplot as plt
import seaborn as sns
# %matplotlib inline
I receive the below error.
File "g:/My Drive/M/importlibrary.py", line 5, in <module>
import pandas
File "C:\Users\M\Anaconda3\lib\site-packages\pandas\__init__.py", line 19, in <module>
"Missing required dependencies {0}".format(missing_dependencies))
ImportError: Missing required dependencies ['numpy']
I try to search for several similar issues and most of the solution ask to first uninstall and then install NumPy and Pandas using the below code,
pip3 uninstall pandas
pip3 uninstall numpy
However, I have followed this workaround but the problem did not resolve. The version of python that I am using is,
Python 3.6.8 :: Anaconda, Inc.
Please help if you can.
Is there a reason why you don't install Numpy/Pandas using anaconda (conda install -c anaconda numpy/pandas)? Did you run Jupyter from inside anaconda when it worked? I suggest going to terminal and figuring out where your modules are installed (i.e. if they are inside the anaconda folders, or somewhere where anaconda has access to).
In general, I'd advise against installing python packages for anaconda using pip, just use conda's package manager if you can. This question seems related. In your case, have you tried uninstalling the pip variant and reinstalling using conda?
The problem is resolved by uninstalling the Anaconda. I checked the control panel of the PC and found that there are multiple instances of python. VS Code uses Python 3.6.8 while Anaconda uses python 3.8. So, I uninstall 3.8, and then reinstall pandas,
pip3 uninstall pandas
pip3 install pandas
The error is no more.

How can I install modules in Mac OS Terminal?

I want to install some modules for Telegram Bots and I always get errors like:
File "test.py", line 7, in <module>
import spotipy
ModuleNotFoundError: No module named 'spotipy'
I tried to install spotipy with pip, pip3 and apt.
How is it done? Or generally how do I import modules?
Thank you.
From the spotipy README:
If you already have Python on your system you can install the library simply by downloading the distribution, unpack it and install in the usual fashion:
python setup.py install
You can also install it using a popular package manager with
pip install spotipy
or
easy_install spotipy
Make sure your pip version matches your python version (pip --version and python --version should both be Python3 or Python2).
To import the module, use one of the following statements (see python3 documentation):
import numpy
import numpy as np
from numpy import array

Mac OS X: "ModuleNotFoundError: No module named 'numpy'"

After I have reinstalled Anaconda, I can not import NumPy any more on Python 3:
import numpy as np
Output:
ModuleNotFoundError: No module named 'numpy'
I have tried
pip install numpy
I try to install it again, but I get:
pip install numpy
Output:
Requirement already satisfied: numpy in /anaconda3/lib/python3.7/site-packages (1.16.3)
Screenshot of some of the above
This command worked for me
python3 -m pip install numpy
You probably have multiple NumPy versions installed on your system and need to manually delete the old one.
Open Terminal and run:
pip list
Remember or notate the NumPy version from the list
Then run Python in Terminal or write and execute this code in your IDE:
import numpy
print(numpy)
print(numpy.version)
This should print two lines: numpy package location + numpy version like this:
<module 'numpy' from '/usr/local/lib/python2.7/site-packages/numpy/init.pyc'>
1.16.1
If the NumPy version reported here is different than the one reported by pip list, then go to the NumPy package location printed above and delete that package folder
Try importing NumPy now. If you previously installed it, it should work. If you didn't install it then go and install it now. After installation all should work fine.
You are using a Conda environment to run your program. So you should run:
conda install numpy
If you use IDE like PyCharm, it will be easy to install packages by a mouse click (Install packages).

No module named 'pandas_datareader' in Jupyter (Anaconda) after I run pip3 install pandas_datareader

I am trying to learn pandas and want to load some stocks data. I was following a course which advised me to load pandas.io.data, but this did not work as io.data was depreciated. So I decided to use pandas-datareader instead. But I am struggling to instal it on mac in Anaconda (Jupiter notebook).
First time I run import pandas_datareader as pdweb I got ModuleNotFoundError: No module named 'pandas_datareader'. Not surprising as I never used this before so I run pip3 install pandas_datareader in Terminal which successfully installed itself. However, Jupiter notebook is still giving me the same error. At this point, I tried running in Terminal conda install -c https://conda.anaconda.org/anaconda pandas-datareader but it did not work as -bash: conda: command not found.
Please help. I am looking for a detailed explanation as I am not too techie.
What I run in Jupiter
import numpy as np
from pandas import Series, DataFrame
import pandas as pd
import pandas_datareader as pdweb
import datetime
Result
---------------------------------------------------------------------------
ModuleNotFoundError Traceback (most recent call last)
<ipython-input-6-da568f513c93> in <module>
2 from pandas import Series, DataFrame
3 import pandas as pd
----> 4 import pandas_datareader as pdweb
5 import datetime
ModuleNotFoundError: No module named 'pandas_datareader'
Just run
conda install -c anaconda pandas-datareader
as per instructions here.
In my experience, if you're using conda, you should never install with pip unless you're sure conda doesn't have it. Try searching anaconda.org to see which -c source to use.
The problem was with conda command not being set up during the installation of Anaconda. I solved this by removing Anaconda with App Cleaner & Uninstaller Pro (free soft) and reinstalling later version.
After reinstallation of Anaconda command below worked like a charm.
conda install -c anaconda pandas-datareader
If you using Anaconda and still have issues installing panads-datareader using the conda command 'conda install -c anaconda pandas-datareader'. or the installation is successful but the import pandas_datareader.data as web still gives an error.
Locate where your 'site-packages % ' directory and cd to the site-packages % dir and then run the installation command 'conda install -c anaconda pandas-datareader '. It will work.
For the install, try using
pip
instead of
pip3

Problems installing PyGame into my Anaconda copy of Python on my macbook pro [duplicate]

So, I have installed Anaconda3 64 bit and TensorFlow, matplotlib, and I have also installed pygame, but I still got an error saying ModuleNotFoundError: No module named 'pygame' and ModuleNotFoundError: No module named 'pygame'
In Anaconda, I have made a new environment and that has all of the packages I have installed and I open jupyter notebook from this environment. Still the error is there.
In Anaconda command prompt:
(base) C:\Users\Eszter>pip install pygame
Requirement already satisfied: pygame in c:\users\eszter\anaconda3\lib\site-packages (2.0.1)
Part of the code is this:
**
import numpy as np
import matplotlib.pyplot as plt
import pygame
from agent import Agent
**
No module named 'pygame'
No module named 'agent'
Anybody can help me with this? I really appreciated it.
Use conda install from anaconda prompt instead of pip
conda install pygame

Resources