issues in importing nltk, giving errors when ran on python3 prompt - nltk

I have installed nltk on python3.5 version using command:
sudo apt-get install python3-nltk
when this did not work, I also tried using pip
when I tried checking the installations on python3 prompt it is giving me the error as this:
enter image description here
how can I resolve this error?

You can install NLTK through PIP. First of all you have to install pip for python3.
sudo apt-get install python3-pip
then check if pip installed successfully by running:
pip3 -V
and you have to take something like this
pip 9.0.1 from /usr/lib/python3.6/site-packages (python 3.6)
After use pip3 to install nltk by running:
sudo pip3 install -U nltk

Related

How can I fix this problem while dowloading pygame? [duplicate]

I'm trying to install Pygame. I am running Windows 7 with Enthought Python Distribution. I successfully installed pip, but when I try to install Pygame using pip, I get the following error:
"Could not install requirement Pygame because of HTTP error HTTP error
400: Bad request for URL ..."
I can't find anything about this issue with a Google search, but I did find another Stack Overflow question that prompted the asker to use the following command:
pip install hg+http://bitbucket.org/pygame/pygame
This gave me the following error:
Cannot find command hg
I'm not sure what else to do, as everything I find with a Google search is for Mac, so I don't know how well I can follow those instructions on Windows.
Steps to install PyGame using pip
Install build dependencies (on linux):
sudo apt-get build-dep python-pygame
Install mercurial to use hg (on linux):
sudo apt-get install mercurial
On Windows you can use the installer: Download
Use pip to install PyGame:
pip install hg+http://bitbucket.org/pygame/pygame
If the above gives freetype-config: not found error (on Linux), then try sudo apt-get install libfreetype6-dev and then repeat 3.
Alternative way:
# Grab source
hg clone https://bitbucket.org/pygame/pygame
# Finally build and install
cd pygame
python setup.py build
sudo python setup.py install
Try doing this:
sudo apt-get install mercurial
sudo pip install hg+http://bitbucket.org/pygame/pygame
An update to this may be required, as it stands in version 1.9.1 it should simply install using:
pip install pygame
However, it look like there is a bug with their pypi repository, see:
https://bitbucket.org/pygame/pygame/issues/59/pygame-has-no-pypi-page-and-cant-be
So, if you want the most recent release, you have to point directly at the ftp file ala:
pip install http://www.pygame.org/ftp/pygame-1.9.1release.tar.gz
I suppose this will be fixed in the 1.9.2 release but for now this works.
I would note that the answer supplied by Pratyush works as well, but requires the user to install mercurial if they don't have it and downloads the trunk version, so really, not ideal unless you absolutely need it.
Caveat: I'm not familiar with the Enthought Distribution, so this might not help.
As you're trying to install on Windows, if you don't want to have to mess around with C compilers, there are pre-built binary wheels for pygame here: http://www.lfd.uci.edu/~gohlke/pythonlibs/#pygame
Select a package appropriate to you python version[0] and Windows architecture [1]. Download to C:\Users\User\Download\pip install E:\env\pygame-1.9.2a0-cp27-none-win_amd64.whl and install with pip install E:\env\pygame-1.9.2a0-cp27-none-win_amd64.whl
Mercurial binaries can be found on the same page, if you would like to install from source. This method would mean compiling pygame from source, for which you probably want to use this compiler package.
[0] python --version
[1] powershell "gwmi win32_operatingsystem | select osarchitecture"
The command below worked for me on Mac OS X El Capitan:
pip3 install pygame
Install on MAC:
brew install homebrew/python/pygame
Just
sudo pip install pygame
worked for me
Had this issue on macOS Sierra, where apt-get doesn't work.
Managed to solve the issue through the following steps:
First I had to install the Mercurial via Brew:
brew install mercurial
Then, I had to install Pygame dependencies:
brew install sdl sdl_image sdl_mixer sdl_ttf smpeg portmidi
Finally I used pip3 to install Pygame:
pip3 install pygame
Hope this helps!
Try
python3 -m pip install -U pygame --user
This worked twice for me on windows 7 and windows 10
The most current, the best way to install pygame is always available at:
https://www.pygame.org/wiki/GettingStarted
How to use pip depends on the operating system. So unless you have always updated and tested answers for 15 different operating systems then just send people to that page. All answers to this question are wrong for various different operating systems.
Currently, for windows, this is the way to install it in the cmd prompt. (If you already have pip installed, and people know what pip is... best just send people to the GettingStarted page).
py -m pip install pygame --user
I did use these instructions here from the official site.
But i had to change the python3 part of the command to just py.
Try: python -m pip install pygame
Or: py -m pip install pygame
Try pip install pygame or pip3 install pygame.
These should work for you.
If this does not work for you put -m before pip and python before
-m.
If putting -m does not work try reinstalling python
If you are working on windows, the command below should work fine
pip install pygame
If you are working on Linux, the command below should work fine
sudo apt-get install python-pygame
Type this in command prompt
pip install pygame
or
py -m pip install pygame
WINDOWS
If you are on a windows 10 device then you should use this command but first make sure you have Python installed from https://python.org, if you do run this in command prompt
py --version
and then whatever version it says you have (which you downloaded) keep it in mind we will use it later for now just incase try to upgrade pip incase you are on a outdated version I will be using 3.9 for the version for the rest of this as an example
py -3.9 -m pip --upgrade pip
After that if you have it already satisfied or it upgraded run this command in command prompt
py -3.9 -m pip install pygame
And wait for it to download
And to make sure it worked run this
py -3.9 -m pygame --version
If it shows the version you downloaded it!
MacOS
For MacOS do the same but then run this command to install it
python3 -m pip install -U pygame --user
or if it wont work
py -3.9 -m pip install -U pygame --user ( or just pip3 )
to see if it worked run this
python3 -m pygame.examples.aliens
or
py -3.9 -m pygame.examples.aliens
I hope this helped
I have never used Enthought distribution, but you could try to use Anaconda distribution which is also great too.
Anaconda Distribution (Any OS):
From the docs:
Update conda to the current version.
Type the following:
conda update conda
If a newer version of conda is available, type y to update:
Proceed ([y]/n)? y
Check to see if a package you have not installed named
“pygame” is available from the Anaconda repository (must be
connected to the Internet):
conda search pygame
Conda displays a list of all packages with
that name on the Anaconda repository, so we know it is available.
Install this package into the current environment:
conda install pygame
Check to see if the newly installed
program is in this environment:
conda list
Install on Windows (both python 2.7 and 3.7):
pip install pygame
Install on raspberry pi:
sudo pip3 install pygame (python 3.7)
sudo pip install pygame (python 2.7)
I think if you go to Command Prompt and type
py -m pip install pygame
that's what works for me
Here is a way: sudo install pygame Rasberry pi has it ready-installed
Install python 3.8 from python.org
Then install pygame (2.0) like this
pip install pygame==2.0.0.dev10
Make sure script path is registered in environment variables,
Make sure the python path is registered in environment variables,
also you dont have to enter entire url just write like this(windows only I dont use mac)
pip
pip install pygame
hope it work
command to install pygame is:
pip install pygame
run it in command prompt
Try doing this for python3:
python3 -m pip install pygame==1.9.6
and this for python2:
python -m pip install pygame==1.9.6
You don't have to type in the entire url. Just simply go to command prompt (windows) or terminal (mac) and then type in:
[windows] pip install pygame
[mac] python -m install pygame
hopefully that works :)
To install pygame with pip, use the following commands in the Command Prompt on Windows.
py -m pip download pygame
then...
py -m pip install pygame
You only have to do the download pygame one if it doesn't work when you use the install pygame command by itself.
You type py -m to show that it is using the module pip, which can be accessed through the command prompt.
This is for Windows. For Mac OS, use python -m pip install pygame
I know that there are already lot's of answers, but if you want to download a specific version of pygame, you can use pip:
pip install pygame==1.9.6
Pygame 1.9.6 is the latest version at the time of writing.
Pygame tells you how to install it here, in my personal experience this is what I do on windows to install it, open up command prompt and type python -m pip install pygame if that fails, check if you have more than one version of python installed if so you need to specify what version for example python3.5 -m pip install pygame the reason we do this from command prompt is that in the Python shell it doesn't understand what pip install is just to break it down a little python -m calls a python module in this case we want pip the next two arguments are what we want pip to do and what module/addon we want the action to be applied too

Working in Python 3.7.3 but NOT working in 3.9.6 [duplicate]

I'm trying to install Pygame. I am running Windows 7 with Enthought Python Distribution. I successfully installed pip, but when I try to install Pygame using pip, I get the following error:
"Could not install requirement Pygame because of HTTP error HTTP error
400: Bad request for URL ..."
I can't find anything about this issue with a Google search, but I did find another Stack Overflow question that prompted the asker to use the following command:
pip install hg+http://bitbucket.org/pygame/pygame
This gave me the following error:
Cannot find command hg
I'm not sure what else to do, as everything I find with a Google search is for Mac, so I don't know how well I can follow those instructions on Windows.
Steps to install PyGame using pip
Install build dependencies (on linux):
sudo apt-get build-dep python-pygame
Install mercurial to use hg (on linux):
sudo apt-get install mercurial
On Windows you can use the installer: Download
Use pip to install PyGame:
pip install hg+http://bitbucket.org/pygame/pygame
If the above gives freetype-config: not found error (on Linux), then try sudo apt-get install libfreetype6-dev and then repeat 3.
Alternative way:
# Grab source
hg clone https://bitbucket.org/pygame/pygame
# Finally build and install
cd pygame
python setup.py build
sudo python setup.py install
Try doing this:
sudo apt-get install mercurial
sudo pip install hg+http://bitbucket.org/pygame/pygame
An update to this may be required, as it stands in version 1.9.1 it should simply install using:
pip install pygame
However, it look like there is a bug with their pypi repository, see:
https://bitbucket.org/pygame/pygame/issues/59/pygame-has-no-pypi-page-and-cant-be
So, if you want the most recent release, you have to point directly at the ftp file ala:
pip install http://www.pygame.org/ftp/pygame-1.9.1release.tar.gz
I suppose this will be fixed in the 1.9.2 release but for now this works.
I would note that the answer supplied by Pratyush works as well, but requires the user to install mercurial if they don't have it and downloads the trunk version, so really, not ideal unless you absolutely need it.
Caveat: I'm not familiar with the Enthought Distribution, so this might not help.
As you're trying to install on Windows, if you don't want to have to mess around with C compilers, there are pre-built binary wheels for pygame here: http://www.lfd.uci.edu/~gohlke/pythonlibs/#pygame
Select a package appropriate to you python version[0] and Windows architecture [1]. Download to C:\Users\User\Download\pip install E:\env\pygame-1.9.2a0-cp27-none-win_amd64.whl and install with pip install E:\env\pygame-1.9.2a0-cp27-none-win_amd64.whl
Mercurial binaries can be found on the same page, if you would like to install from source. This method would mean compiling pygame from source, for which you probably want to use this compiler package.
[0] python --version
[1] powershell "gwmi win32_operatingsystem | select osarchitecture"
The command below worked for me on Mac OS X El Capitan:
pip3 install pygame
Install on MAC:
brew install homebrew/python/pygame
Just
sudo pip install pygame
worked for me
Had this issue on macOS Sierra, where apt-get doesn't work.
Managed to solve the issue through the following steps:
First I had to install the Mercurial via Brew:
brew install mercurial
Then, I had to install Pygame dependencies:
brew install sdl sdl_image sdl_mixer sdl_ttf smpeg portmidi
Finally I used pip3 to install Pygame:
pip3 install pygame
Hope this helps!
Try
python3 -m pip install -U pygame --user
This worked twice for me on windows 7 and windows 10
The most current, the best way to install pygame is always available at:
https://www.pygame.org/wiki/GettingStarted
How to use pip depends on the operating system. So unless you have always updated and tested answers for 15 different operating systems then just send people to that page. All answers to this question are wrong for various different operating systems.
Currently, for windows, this is the way to install it in the cmd prompt. (If you already have pip installed, and people know what pip is... best just send people to the GettingStarted page).
py -m pip install pygame --user
I did use these instructions here from the official site.
But i had to change the python3 part of the command to just py.
Try: python -m pip install pygame
Or: py -m pip install pygame
Try pip install pygame or pip3 install pygame.
These should work for you.
If this does not work for you put -m before pip and python before
-m.
If putting -m does not work try reinstalling python
If you are working on windows, the command below should work fine
pip install pygame
If you are working on Linux, the command below should work fine
sudo apt-get install python-pygame
Type this in command prompt
pip install pygame
or
py -m pip install pygame
WINDOWS
If you are on a windows 10 device then you should use this command but first make sure you have Python installed from https://python.org, if you do run this in command prompt
py --version
and then whatever version it says you have (which you downloaded) keep it in mind we will use it later for now just incase try to upgrade pip incase you are on a outdated version I will be using 3.9 for the version for the rest of this as an example
py -3.9 -m pip --upgrade pip
After that if you have it already satisfied or it upgraded run this command in command prompt
py -3.9 -m pip install pygame
And wait for it to download
And to make sure it worked run this
py -3.9 -m pygame --version
If it shows the version you downloaded it!
MacOS
For MacOS do the same but then run this command to install it
python3 -m pip install -U pygame --user
or if it wont work
py -3.9 -m pip install -U pygame --user ( or just pip3 )
to see if it worked run this
python3 -m pygame.examples.aliens
or
py -3.9 -m pygame.examples.aliens
I hope this helped
I have never used Enthought distribution, but you could try to use Anaconda distribution which is also great too.
Anaconda Distribution (Any OS):
From the docs:
Update conda to the current version.
Type the following:
conda update conda
If a newer version of conda is available, type y to update:
Proceed ([y]/n)? y
Check to see if a package you have not installed named
“pygame” is available from the Anaconda repository (must be
connected to the Internet):
conda search pygame
Conda displays a list of all packages with
that name on the Anaconda repository, so we know it is available.
Install this package into the current environment:
conda install pygame
Check to see if the newly installed
program is in this environment:
conda list
Install on Windows (both python 2.7 and 3.7):
pip install pygame
Install on raspberry pi:
sudo pip3 install pygame (python 3.7)
sudo pip install pygame (python 2.7)
I think if you go to Command Prompt and type
py -m pip install pygame
that's what works for me
Here is a way: sudo install pygame Rasberry pi has it ready-installed
Install python 3.8 from python.org
Then install pygame (2.0) like this
pip install pygame==2.0.0.dev10
Make sure script path is registered in environment variables,
Make sure the python path is registered in environment variables,
also you dont have to enter entire url just write like this(windows only I dont use mac)
pip
pip install pygame
hope it work
command to install pygame is:
pip install pygame
run it in command prompt
Try doing this for python3:
python3 -m pip install pygame==1.9.6
and this for python2:
python -m pip install pygame==1.9.6
You don't have to type in the entire url. Just simply go to command prompt (windows) or terminal (mac) and then type in:
[windows] pip install pygame
[mac] python -m install pygame
hopefully that works :)
To install pygame with pip, use the following commands in the Command Prompt on Windows.
py -m pip download pygame
then...
py -m pip install pygame
You only have to do the download pygame one if it doesn't work when you use the install pygame command by itself.
You type py -m to show that it is using the module pip, which can be accessed through the command prompt.
This is for Windows. For Mac OS, use python -m pip install pygame
I know that there are already lot's of answers, but if you want to download a specific version of pygame, you can use pip:
pip install pygame==1.9.6
Pygame 1.9.6 is the latest version at the time of writing.
Pygame tells you how to install it here, in my personal experience this is what I do on windows to install it, open up command prompt and type python -m pip install pygame if that fails, check if you have more than one version of python installed if so you need to specify what version for example python3.5 -m pip install pygame the reason we do this from command prompt is that in the Python shell it doesn't understand what pip install is just to break it down a little python -m calls a python module in this case we want pip the next two arguments are what we want pip to do and what module/addon we want the action to be applied too

Linux Ubuntu 18.04 - Error loading MySQLdb module. Did you install mysqlclient?

I'm getting the following error message while running my Django REST project with MySQL database in pipenv.
raise ImproperlyConfigured(
django.core.exceptions.ImproperlyConfigured: Error loading MySQLdb module.
Did you install mysqlclient?
This seems like a very common problem (please don't mark as duplication), but after trying all the possible solutions I'm still getting the same issue..
A few things I tried:
pip3 install mysqlclient
pip3 install python3.6-dev
pip3 install mysql-client
pip3 install libsqlclient-dev
pip3 install libssl-dev
What could still be the problem?
It's a Linux Ubuntu 18.04 server with Plesk. Python version 3.8.
mysqlclient has a dependency on the mysql client & dev packages being installed. In order to fix this on ubuntu, you have to use apt-get to install a couple of mysql packages.
In your case, it looks like the missing mysql_config might be missing on your system. You can fix that by installing libmysqlclient-dev on ubuntu bionic.
another way
install the follwing packages.
sudo apt-get install python3.8-dev
sudo apt-get install mysql-client
sudo apt-get install libsqlclient-dev
sudo apt-get install libssl-dev
other method
pip install pymysql
Then, edit the init.py file in your project origin dir(the same as settings.py)
add:
import pymysql
pymysql.install_as_MySQLdb()
You should install libmysqlclient-dev: sudo apt-get install libmysqlclient-dev
I had to install this.
sudo apt install libpython3.8-dev
Now it works.

how to install pyaudio module in google cloud shell?

Error:
raise AttributeError("Could not find PyAudio; check installation")
AttributeError: Could not find PyAudio; check installation
I tried all of these commands:
sudo pip install pyaudio,
sudo apt-get install python-pyaudio ,
sudo pip install pyaudio ,
sudo pip install --upgrade pyaudio.
First, undo what you have done.
Then try to install it following their documentation for Debian based versions:
$ sudo apt install portaudio19-dev python-all-dev
followed by
$ sudo apt install python-pyaudio for python 2 version
OR
$ sudo apt install python-pyaudio for python 3 version.

Unable to install the Elastic Beanstalk CLI on Ubuntu

I am trying to install the Elastic Beanstalk CLI (awsebcli) on a fresh Ubuntu 14.04 (on Linux subsystem for Windows) using sudo pip install awsebcli, but launching the eb command just returns the following error:
flavien#XPS-FLAVIEN:~$ eb
Traceback (most recent call last):
File "/usr/local/bin/eb", line 6, in <module>
from pkg_resources import load_entry_point
File "/usr/local/lib/python2.7/dist-packages/pkg_resources/__init__.py", line 3036, in <module>
#_call_aside
File "/usr/local/lib/python2.7/dist-packages/pkg_resources/__init__.py", line 3020, in _call_aside
f(*args, **kwargs)
File "/usr/local/lib/python2.7/dist-packages/pkg_resources/__init__.py", line 3049, in _initialize_master_working_set
working_set = WorkingSet._build_master()
File "/usr/local/lib/python2.7/dist-packages/pkg_resources/__init__.py", line 654, in _build_master
ws.require(__requires__)
File "/usr/local/lib/python2.7/dist-packages/pkg_resources/__init__.py", line 968, in require
needed = self.resolve(parse_requirements(requirements))
File "/usr/local/lib/python2.7/dist-packages/pkg_resources/__init__.py", line 854, in resolve
raise DistributionNotFound(req, requirers)
pkg_resources.DistributionNotFound: The 'termcolor==1.1.0' distribution was not found and is required by awsebcli
Any idea what might be going wrong?
You can reinstall awsebcli with below command if you have issues after installing it:
sudo pip3 install awsebcli --force-reinstall --upgrade
Once its installed check where its installed:
which eb
$ /usr/local/bin/eb #i got eb installed in this path
Next set the path:
export PATH=/usr/local/bin:$PATH
Then run
eb --version
EB CLI 3.14.6 (Python 3.5.2) #this is my installed version
First install the pip separably and try with this command
pip install --upgrade --user awsebcli
I had awsebcli being installed for Python 2.7 but for some reason running eb needed them for Python 3.x so doing this worked :
$ sudo -H pip3 install --upgrade --user awsebcli
After installing all the required wheels eb worked fine :
$ eb --version
EB CLI 3.14.3 (Python 3.5.2)
Also don't forget to add ~/.local/bin to your PATH variable in ~/.bash_profile
The previous answer helped me to figure this one out.
My detail, I had to install a newer version of python than 2.7, one that supported the --trusted-host switch to allow me to get all of my dependencies:
What I ran:
pip --cert zxroot.pem --trusted-host pypi.python.org --proxy [ProxyServer] install --upgrade --user awsebcli
Once I ran that reinstall using the --upgrade switch, eb finally worked:
eb --version
EB CLI 3.10.5 (Python 3.3.1)
I know this is very specific to my particulars but it might help someone else.
Good luck.
The problem is you are missing quite a few applications required by the scripts to compile.
The following installation steps are required prior to running the EB CLI scripts.
As I'm a windows user I created a clean VirtualBox VM install of Ubuntu 18.04.2
Update Ubuntu
sudo apt update
sudo apt upgrade
sudo reboot
Install curl,wget
sudo apt install curl
sudo apt install wget
Install zlib
sudo apt-get install zlib1g-dev
Install libffi
sudo apt-get install libffi libffi5-dev
Install OpenSSL
sudo apt-get install libssl-dev
Install gcc
sudo apt-get install build-essential
sudo apt install libx11-dev
gcc --version
make -v
Install Python 3.7
sudo apt install software-properties-common
sudo add-apt-repository ppa:deadsnakes/ppa
sudo apt install python3.7
python3.7 --version
alias python='python3.7'
Install Git
sudo apt install git
After this run the EB CLI
You should see these 5 successful progress steps
Creating exclusive virtualenv for EBCLI
Activating virtualenv
Installing EBCLI
Creating EB wrappers
Finishing up
Success!
Try This:
sudo chown -R username:username ~/.local/
# add to ./*shrc
export PATH=$PATH:~/.local/bin/
pip install --upgrade --user awsebcli
eb --version
#EB CLI 3.10.1 (Python 2.7.1)