Unable to install NLTK with Python 3.7 - python

The NLTK docs say it supports Python 3.7. However, when I try to install it with:
virtualenv -p python3.7 .env
. .env/bin/activate
pip install nltk
I get the error:
Collecting nltk
Using cached https://files.pythonhosted.org/packages/f6/1d/d925cfb4f324ede997f6d47bea4d9babba51b49e87a767c170b77005889d/nltk-3.4.5.zip
ERROR: Command errored out with exit status 1:
command: /path/to/my/project/.env/bin/python3.7 -c 'import sys, setuptools, tokenize; sys.argv[0] = '"'"'/tmp/pip-install-12ut35ws/nltk/setup.py'"'"'; __file__='"'"'/tmp/pip-install-12ut35ws/nltk/setup.py'"'"';f=getattr(tokenize, '"'"'open'"'"', open)(__file__);code=f.read().replace('"'"'\r\n'"'"', '"'"'\n'"'"');f.close();exec(compile(code, __file__, '"'"'exec'"'"'))' egg_info --egg-base pip-egg-info
cwd: /tmp/pip-install-12ut35ws/nltk/
Complete output (1 lines):
error in nltk setup command: 'install_requires' must be a string or list of strings containing valid project/version requirement specifiers; Expected version spec in singledispatch; python_version < "3.4" at ; python_version < "3.4"
----------------------------------------
ERROR: Command errored out with exit status 1: python setup.py egg_info Check the logs for full command output.
The error message sounds like NLTK only supports Python < 3.4, but that doesn't make any sense. What am I doing wrong?

It is because the package format was not supported by the distutils, which indicates the package tools may be too old.
Upgrade pip in the virtual environment.
pip install -U pip
pip install -U setuptools
Retry to install nltk.
. .env/bin/activate
pip install nltk
If this still doesn't work. Provide log from pip install nltk -v.

First of all you have to upgrade your pip by using this command
python -m pip install –upgrade pip
First of all you have to navigate to the location of the pip folder
C:\Users\Admin>cd C:\Python\Scripts
Then run this command
pip3 install nltk
hope it will work!

Related

pip metadata-generation-failed when i wanna to download demjson [duplicate]

version pip 21.2.4
python 3.6
The command:
pip install -r requirements.txt
The content of my requirements.txt:
mongoengine==0.19.1
numpy==1.16.2
pylint
pandas==1.1.5
fawkes
The command is failing with this error
ERROR: Command errored out with exit status 1:
command: /Users/*/Desktop/ml/*/venv/bin/python -c 'import io, os, sys, setuptools, tokenize; sys.argv[0] = '"'"'/private/var/folders/kn/0y92g7x55qs7c42tln4gwhtm0000gp/T/pip-install-soh30mel/mongoengine_89e68f8427244f1bb3215b22f77a619c/setup.py'"'"'; __file__='"'"'/private/var/folders/kn/0y92g7x55qs7c42tln4gwhtm0000gp/T/pip-install-soh30mel/mongoengine_89e68f8427244f1bb3215b22f77a619c/setup.py'"'"';f = getattr(tokenize, '"'"'open'"'"', open)(__file__) if os.path.exists(__file__) else io.StringIO('"'"'from setuptools import setup; setup()'"'"');code = f.read().replace('"'"'\r\n'"'"', '"'"'\n'"'"');f.close();exec(compile(code, __file__, '"'"'exec'"'"'))' egg_info --egg-base /private/var/folders/kn/0y92g7x55qs7c42tln4gwhtm0000gp/T/pip-pip-egg-info-97994d6e
cwd: /private/var/folders/kn/0y92g7x55qs7c42tln4gwhtm0000gp/T/pip-install-soh30mel/mongoengine_89e68f8427244f1bb3215b22f77a619c/
Complete output (1 lines):
error in mongoengine setup command: use_2to3 is invalid.
----------------------------------------
WARNING: Discarding https://*/pypi/packages/mongoengine-0.19.1.tar.gz#md5=68e613009f6466239158821a102ac084 (from https://*/pypi/simple/mongoengine/). Command errored out with exit status 1: python setup.py egg_info Check the logs for full command output.
ERROR: Could not find a version that satisfies the requirement mongoengine==0.19.1 (from versions: 0.15.0, 0.19.1)
ERROR: No matching distribution found for mongoengine==0.19.1
It looks like setuptools>=58 breaks support for use_2to3:
setuptools changelog for v58
So you should update setuptools to setuptools<58 or avoid using packages with use_2to3 in the setup parameters.
I was having the same problem, pip==19.3.1
I install setuptools==58It worked for me. pip install setuptools==58. The error coming from setuptools==69 that previously run on my device. and Finally saved me setuptools version 58 for this error.
This worked for me.
pip install --upgrade pip setuptools==57.5.0
"pip install setuptools==58" worked for me. The setuptools version was 59 when I upgraded ubuntu to 22.04 and its python 3.10. I started a clean virtual environment for an existings django project. It had just two packages:
`pip list
Package Version
pip 22.0.2
setuptools 59.6.0`
Then I downgrade the setuptools to 58 as pip install setuptools==58.0.0. After that the pip install -r requirements.txt has not such error above.
Upgrading MongoEngine to >= 0.20 would also fix the problem as Python2 support (hence use_2to3) was dropped in 0.20
I'm working on Windows 11 and these solutions didn't work. I installed pybluez2 instead. Your python version >= 3.9 on Windows.
pip install pybluez2

Error while downloading the requirements using pip install (setup command: use_2to3 is invalid.)

version pip 21.2.4
python 3.6
The command:
pip install -r requirements.txt
The content of my requirements.txt:
mongoengine==0.19.1
numpy==1.16.2
pylint
pandas==1.1.5
fawkes
The command is failing with this error
ERROR: Command errored out with exit status 1:
command: /Users/*/Desktop/ml/*/venv/bin/python -c 'import io, os, sys, setuptools, tokenize; sys.argv[0] = '"'"'/private/var/folders/kn/0y92g7x55qs7c42tln4gwhtm0000gp/T/pip-install-soh30mel/mongoengine_89e68f8427244f1bb3215b22f77a619c/setup.py'"'"'; __file__='"'"'/private/var/folders/kn/0y92g7x55qs7c42tln4gwhtm0000gp/T/pip-install-soh30mel/mongoengine_89e68f8427244f1bb3215b22f77a619c/setup.py'"'"';f = getattr(tokenize, '"'"'open'"'"', open)(__file__) if os.path.exists(__file__) else io.StringIO('"'"'from setuptools import setup; setup()'"'"');code = f.read().replace('"'"'\r\n'"'"', '"'"'\n'"'"');f.close();exec(compile(code, __file__, '"'"'exec'"'"'))' egg_info --egg-base /private/var/folders/kn/0y92g7x55qs7c42tln4gwhtm0000gp/T/pip-pip-egg-info-97994d6e
cwd: /private/var/folders/kn/0y92g7x55qs7c42tln4gwhtm0000gp/T/pip-install-soh30mel/mongoengine_89e68f8427244f1bb3215b22f77a619c/
Complete output (1 lines):
error in mongoengine setup command: use_2to3 is invalid.
----------------------------------------
WARNING: Discarding https://*/pypi/packages/mongoengine-0.19.1.tar.gz#md5=68e613009f6466239158821a102ac084 (from https://*/pypi/simple/mongoengine/). Command errored out with exit status 1: python setup.py egg_info Check the logs for full command output.
ERROR: Could not find a version that satisfies the requirement mongoengine==0.19.1 (from versions: 0.15.0, 0.19.1)
ERROR: No matching distribution found for mongoengine==0.19.1
It looks like setuptools>=58 breaks support for use_2to3:
setuptools changelog for v58
So you should update setuptools to setuptools<58 or avoid using packages with use_2to3 in the setup parameters.
I was having the same problem, pip==19.3.1
I install setuptools==58It worked for me. pip install setuptools==58. The error coming from setuptools==69 that previously run on my device. and Finally saved me setuptools version 58 for this error.
This worked for me.
pip install --upgrade pip setuptools==57.5.0
"pip install setuptools==58" worked for me. The setuptools version was 59 when I upgraded ubuntu to 22.04 and its python 3.10. I started a clean virtual environment for an existings django project. It had just two packages:
`pip list
Package Version
pip 22.0.2
setuptools 59.6.0`
Then I downgrade the setuptools to 58 as pip install setuptools==58.0.0. After that the pip install -r requirements.txt has not such error above.
Upgrading MongoEngine to >= 0.20 would also fix the problem as Python2 support (hence use_2to3) was dropped in 0.20
I'm working on Windows 11 and these solutions didn't work. I installed pybluez2 instead. Your python version >= 3.9 on Windows.
pip install pybluez2

How to use pip install while activating virtual environment in python

I've installed a separated python version and activated virtual environment based on it , on CentOs7 when i use the pip install method from offline packages i got this error :
ERROR: Command errored out with exit status 127:
command: /home/awagdy/Documents/reporter-web/venv/bin/python3.7 -c 'import sys, setuptools, tokenize; sys.argv[0] = '"'"'/tmp/pip-install-jlfbivgb/Django/setup.py'"'"'; __file__='"'"'/tmp/pip-install-jlfbivgb/Django/setup.py'"'"';f=getattr(tokenize, '"'"'open'"'"', open)(__file__);code=f.read().replace('"'"'\r\n'"'"', '"'"'\n'"'"');f.close();exec(compile(code, __file__, '"'"'exec'"'"'))' egg_info --egg-base pip-egg-info
cwd: /tmp/pip-install-jlfbivgb/Django/
Complete output (1 lines):
/home/awagdy/Documents/reporter-web/venv/bin/python3.7: error while loading shared libraries: libpython3.7m.so.1.0: cannot open shared object file: No such file or directory
----------------------------------------
ERROR: Command errored out with exit status 127: python setup.py egg_info Check the logs for full command output.
I'm installing from a folder that contains the needed packages downloaded using the command pip download , then installing them offline using pip install -r requirements.txt --no--index --find-links=pkgs
The link below, the person suggests using
easy_install when installing python packages in a virtual environment
example
Using this command helped path/to/python/python3.6 -m pip install -r requirements.txt --no-index --find-links=path/to/pkgs

Installing package halo gives error: 'install_requires' must be a string or list of strings containing valid project/version requirement specifiers

Im trying to install Halo by using,
pip install halo
I get the following error message:
ERROR: Command errored out with exit status 1:
command: /usr/bin/python -c 'import sys, setuptools, tokenize; sys.argv[0] = '"'"'/private/var/folders/9s/vjh90rsn4xl5587hr11qpjjh0000gn/T/pip-install-L5LD_D/halo/setup.py'"'"'; __file__='"'"'/private/var/folders/9s/vjh90rsn4xl5587hr11qpjjh0000gn/T/pip-install-L5LD_D/halo/setup.py'"'"';f=getattr(tokenize, '"'"'open'"'"', open)(__file__);code=f.read().replace('"'"'\r\n'"'"', '"'"'\n'"'"');f.close();exec(compile(code, __file__, '"'"'exec'"'"'))' egg_info --egg-base /private/var/folders/9s/vjh90rsn4xl5587hr11qpjjh0000gn/T/pip-install-L5LD_D/halo/pip-egg-info
cwd: /private/var/folders/9s/vjh90rsn4xl5587hr11qpjjh0000gn/T/pip-install-L5LD_D/halo/
Complete output (3 lines):
/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/distutils/dist.py:267: UserWarning: Unknown distribution option: 'long_description_content_type'
warnings.warn(msg)
error in halo setup command: 'install_requires' must be a string or list of strings containing valid project/version requirement specifiers; Expected ',' or end-of-list in backports.shutil_get_terminal_size>=1.0.0;python_version < '3.3' at ;python_version < '3.3'
----------------------------------------
ERROR: Command errored out with exit status 1: python setup.py egg_info Check the logs for full command output.
My python version is 2.7.10.
I made some research and tried the following solutions,
brew install halo
This did not work and my terminal returned:
Error: No formulae found in taps.
I checked my Formulae in Homebrew and could not find Halo. However, I found other packages so my Homebrew work otherwise.
I tried chaning my python version to 3 by changing alias and installing halo again, and it did not work either.
alias python='python3'
Error massage was the same as for python2, as above.
I need halo for a school lab, and im using Mac.
It looks like it's a known bug for that package:
https://github.com/manrajgrover/halo/issues/79
You just have to update setup tools via: pip install -U setuptools
If that doesn't work, try adding the --user flag: pip install --user -U setuptools
Try this command
pip3 install --user package-name # for Python3
pip install -U setuptools && pip install halo # for Python3
pip install --user package-name # for Python2
pip3 install -U setuptools && pip install halo # for Python2

Google Assistant installation via python - setup.py install for grpcio ... error

I am trying to install GoogleAssistant for my PC using python. I am a beginner at coding in Python. So, I am basically using instructions from various sites. (esp - https://www.lifewire.com/google-assistant-on-windows-4628292 )
I have tried updating python version through
"python -m pip install --upgrade pip."
error: [WinError 2] The system cannot find the file specified
----------------------------------------
*ERROR: Command errored out with exit status 1: 'C:\Users\S K CHOUDHARY\AppData\Local\Programs\Python\Python38-32\python.exe' -u -c 'import sys, setuptools, tokenize; sys.argv[0] = '"'"'C:\\Users\\S K CHOUDHARY\\AppData\\Local\\Temp\\pip-install-gr2pj17q\\grpcio\\setup.py'"'"'; __file__='"'"'C:\\Users\\S K CHOUDHARY\\AppData\\Local\\Temp\\pip-install-gr2pj17q\\grpcio\\setup.py'"'"';f=getattr(tokenize, '"'"'open'"'"', open)(__file__);code=f.read().replace('"'"'\r\n'"'"', '"'"'\n'"'"');f.close();exec(compile(code, __file__, '"'"'exec'"'"'))' install --record 'C:\Users\S K CHOUDHARY\AppData\Local\Temp\pip-record-n9m9wxyy\install-record.txt' --single-version-externally-managed --compile Check the logs for full command output.
What does the above error mean ? How can I fix it ?
WARNING:
WARNING: You are using pip version 19.2.3, however version 19.3.1 is available.
You should consider upgrading via the 'python -m pip install --upgrade pip' command.
C:\WINDOWS\system32>
C:\WINDOWS\system32>python -m pip install --upgrade pip
Requirement already up-to-date: pip in c:\program files\python37\lib\site-packages (19.3.1)
Do look at the WARNING. It says that I ought to have version 19.3.1 but upon running upgrade the very same cmd shows that I am already using the latest version 19.3.1. How is this possible?
I am facing a lot of confusions. Can anyone ALSO recommend some websites for beginners for installing GoogleAssistant on PC. I have tried Github but haven't been able to comprehend it.

Categories