Installing enum34 on Python 3.x breaks pip for Python3.x - python

I used PythonAnywhere to host some Python scripts that required the fbchat module. I installed the module on Python 3.6 (with user scheme) without using virtualenv, and the module installed enum34 as a dependency.
I know enum34 is incompatible with Python versions greater than 3.4. However I can't uninstall it now either because calling pip3.x gives this error:
Traceback (most recent call last):
File "/usr/local/bin/pip3.6", line 4, in <module>
import re
File "/usr/lib/python3.6/re.py", line 142, in <module>
class RegexFlag(enum.IntFlag):
AttributeError: module 'enum' has no attribute 'IntFlag'
and the command $ python3.6 -m pip gives:
Traceback (most recent call last):
File "/usr/lib/python3.6/runpy.py", line 183, in _run_module_as_main
mod_name, mod_spec, code = _get_module_details(mod_name, _Error)
File "/usr/lib/python3.6/runpy.py", line 142, in _get_module_details
return _get_module_details(pkg_main_name, error)
File "/usr/lib/python3.6/runpy.py", line 109, in _get_module_details
__import__(pkg_name)
File "/usr/local/lib/python3.6/dist-packages/pip/__init__.py", line 4, in <module>
import locale
File "/usr/lib/python3.6/locale.py", line 16, in <module>
import re
File "/usr/lib/python3.6/re.py", line 142, in <module>
class RegexFlag(enum.IntFlag):
AttributeError: module 'enum' has no attribute 'IntFlag'
These are the exact steps to reproduce, and the only commands used to get here:
$ pip3.6 install --user fbchat

Just delete the package from your site-packages folder manually.
Locate it first:
python3.6 -c 'import enum; print(enum.__file__)'
then delete the whole enum directory that file lives in, it'll be in a site-packages directory. Delete the enum34-<version>.dist-info file next to it too.
Because you used --user, the package was installed in your user-site directory. You can get the location with the site module too:
python3.6 -m site --user-site
so you can remove the offending package with:
rm -rf `python3.6 -m site --user-site`/enum
rm `python3.6 -m site --user-site`/enum-*.dist-info

Related

Cfgrib is not installed correctly on WSL2 through pip

I'm trying to install cfgrib to my WSL2 Ubuntu however when I type python3 -m cfgrib selfcheck it gives the following error as follows.
Traceback (most recent call last):
File "/home/berke/.local/lib/python3.8/site-packages/cfgrib/messages.py", line 42, in <module>
import pyeccodes.compat as eccodes
ModuleNotFoundError: No module named 'pyeccodes'
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "/usr/lib/python3.8/runpy.py", line 184, in _run_module_as_main
mod_name, mod_spec, code = _get_module_details(mod_name, _Error)
File "/usr/lib/python3.8/runpy.py", line 143, in _get_module_details
return _get_module_details(pkg_main_name, error)
File "/usr/lib/python3.8/runpy.py", line 110, in _get_module_details
__import__(pkg_name)
File "/home/berke/.local/lib/python3.8/site-packages/cfgrib/__init__.py", line 19, in <module>
from .cfmessage import CfMessage
File "/home/berke/.local/lib/python3.8/site-packages/cfgrib/cfmessage.py", line 29, in <module>
from . import messages
File "/home/berke/.local/lib/python3.8/site-packages/cfgrib/messages.py", line 44, in <module>
raise exc
File "/home/berke/.local/lib/python3.8/site-packages/cfgrib/messages.py", line 37, in <module>
from . import bindings as eccodes
File "/home/berke/.local/lib/python3.8/site-packages/cfgrib/bindings.py", line 57, in <module>
raise RuntimeError(f"ecCodes library not found using {LIBNAMES}")
RuntimeError: ecCodes library not found using ['eccodes', 'libeccodes.so', 'libeccodes']
My python version is Python 3.8.2. Is it possible to install cfgrib through pip?
The latest release of cfgrib version 0.9.8.5 at PyPI doesn't declare eccodes or pyeccodes as a dependency, not even as extra. You can install one of them separately:
pip install eccodes
or
pip install pyeccodes
(I don't know what is the difference; cfgrib can use both).
The bug is fixed in the repository but not yet released to PyPI so you can try to install the latest version using git:
pip install --upgrade "git+https://github.com/ecmwf/cfgrib.git#egg=cfgrib"

My pip is broken on Windows, how can I fix it?

Whenever I try to use pip, using any command I get this:
Traceback (most recent call last):
File "C:\Program Files\WindowsApps\PythonSoftwareFoundation.Python.3.8_3.8.1008.0_x64__qzc5n2dfsdra8p0\lib\runpy.py", line 194, in _run_module_as_main
return _run_code(code, main_globals, None,
File "C:\Program Files\WindowsApps\PythonSoftwareFoundation.Python.3.8_3.8.1008.0_x64__qzc5n2dfsd8p0\lib\runpy.py", line 87, in _run_code
exec(code, run_globals)
File "C:\Users\SE\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.8_q3.8_qzc5n2dfsd8p0\LocalCache\local-packages\Python38\site-packages\pip\__main__.py", line 23, in <module>
from pip._internal.cli.main import main as _main # isort:skip # noqa
File "C:\Users\SE\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.8_qzc5n2dfsd8p0\LocalCache\local-packages\Python38\site-packages\pip\_internal\cli\main.py", line 10, in <module>
from pip._internal.cli.autocompletion import autocomplete
File "C:\Users\SE\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.8_qzc5n2dfsd8p0\LocalCache\local-packages\Python38\site-packages\pip\_internal\cli\autocompletion.py", line 9, in <module>
from pip._internal.cli.main_parser import create_main_parser
File "C:\Users\SE\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.8_qzc5n2dfsd8p0\LocalCache\local-packages\Python38\site-packages\pip\_internal\cli\main_parser.py", line 7, in <module>
from pip._internal.cli import cmdoptions
File "C:\Users\SE\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.8_qzc5n2dfsd8p0\LocalCache\local-packages\Python38\site-packages\pip\_internal\cli\cmdoptions.py", line 24, in <module>
from pip._internal.cli.progress_bars import BAR_TYPES
File "C:\Users\SE\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.8_qzc5n2dfsd8p0\LocalCache\local-packages\Python38\site-packages\pip\_internal\cli\progress_bars.py", line 8, in <module>
from pip._vendor.progress.bar import Bar, FillingCirclesBar, IncrementalBar
ModuleNotFoundError: No module named 'pip._vendor.progress'
PS C:\Users\SE> No module named 'pip._vendor.progress'No module named 'pip._vendor.progress'
I am on Windows 10, 64 bit, Python version 3.7.7.
I cannot use pip, how can I fix it?
If pip is broken after an attempted upgrade to a newer version, try the following:
Download get-pip.py and "Save As" the file using right-click.
Open a command prompt as an administrator
cd to the path where you saved the file, in my case
cd C:\Users\xyz\Downloads> then type python get-pip.py. It will install all required packages, such as wheel and pip.
To check if it installed correctly, type pip --version in the command line.
Hope my answer helps someone. Happy coding. 🙂
Try doing python -m pip install pytest. This should install it, and it will make it usable by your IDE.
Hope this helps!
You could follow the equivalent steps mentioned here and here (Both are closed issues on pip's github page) on your windows machine.
On windows you can do this:
python -m pip uninstall pip setuptools # Sometimes setuptools might be the problem
This will uninstall pip and setuptools.
After which you can reinstall them using
python -m ensurepip
This will install pip and setuptools.
I have tried this on my windows 10 machine running Python 3.7.4!

Strange error when trying to install PIP

Trying install PIP.
I have python 2.7 installed on Windows 7 (32-bit)
I created a file called get-pip.py as instructed here: https://pip.pypa.io/en/stable/installing/
When I run that file with python, I get the following error. The user account has admin rights.
Does anyone know what is going on?
C:\Python27>python get-pip.py
Traceback (most recent call last):
File "get-pip.py", line 20061, in <module>
main()
File "get-pip.py", line 194, in main
bootstrap(tmpdir=tmpdir)
File "get-pip.py", line 82, in bootstrap
import pip
File "c:\users\sek~1.sek\appdata\local\temp\tmpvkex0l\pip.zip\pip\__init__.py", line 21, in <module>
File "c:\users\sek~1.sek\appdata\local\temp\tmpvkex0l\pip.zip\pip\_vendor\requests\__init__.py", line 62, in <module>
File "c:\users\sek~1.sek\appdata\local\temp\tmpvkex0l\pip.zip\pip\_vendor\requests\packages\__init__.py", line 27, in <module>
File "c:\users\sek~1.sek\appdata\local\temp\tmpvkex0l\pip.zip\pip\_vendor\requests\packages\urllib3\__init__.py", line 8, in <module>
File "c:\users\sek~1.sek\appdata\local\temp\tmpvkex0l\pip.zip\pip\_vendor\requests\packages\urllib3\connectionpool.py", line 41, in <module>
File "c:\users\sek~1.sek\appdata\local\temp\tmpvkex0l\pip.zip\pip\_vendor\requests\packages\urllib3\request.py", line 7, in <module>
File "c:\users\sek~1.sek\appdata\local\temp\tmpvkex0l\pip.zip\pip\_vendor\requests\packages\urllib3\filepost.py", line 9, in <module>
File "c:\users\sek~1.sek\appdata\local\temp\tmpvkex0l\pip.zip\pip\_vendor\requests\packages\urllib3\fields.py", line 2, in <module>
File "C:\Python27\lib\email\utils.py", line 313
fallback charset='us-ascii'):
^
SyntaxError: invalid syntax
C:\Python27>
Do I need to install pip?
pip is already installed if you're using Python 2 >=2.7.9 or Python 3 >=3.4 binaries downloaded from python.org, but you'll need to upgrade pip.
Just add pip to your environment path:
<python install dir>/Scripts/
Which can be easily done using an elevated command-prompt:
setx path "%path%;<python install dir>/Scripts/"
Then, upgrade it:
python -m pip install -U pip

Using Python 3 when Python 2.7 is default, pip install error

I originally had both python 2.7 and python 3 installed with python 2.7 as my default in PATH. I needed to run a script using python 3 but could not set it as my default python in PATH for some reason. After just uninstalling python 2.7 I opened 3 and ran the command python get-pip.py install which gave me this error
C:\Python30>python get-pip.py install
Traceback (most recent call last):
File "c:\users\jacob\appdata\local\temp\tmplqxvtx\pip.zip\pip\compat\__init__.py", line 16, in <module>
ImportError: cannot import name OrderedDict
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "get-pip.py", line 19177, in <module>
main()
File "get-pip.py", line 194, in main
bootstrap(tmpdir=tmpdir)
File "get-pip.py", line 82, in bootstrap
import pip
File "c:\users\jacob\appdata\local\temp\tmplqxvtx\pip.zip\pip\__init__.py", line 14, in <module>
File "c:\users\jacob\appdata\local\temp\tmplqxvtx\pip.zip\pip\utils\__init__.py", line 22, in <module>
File "c:\users\jacob\appdata\local\temp\tmplqxvtx\pip.zip\pip\compat\__init__.py", line 18, in <module>
File "c:\users\jacob\appdata\local\temp\tmplqxvtx\pip.zip\pip\compat\ordereddict.py", line 25, in <module>
ImportError: No module named UserDict
I already tried python -m pip install (module name) but it returns No module named pip
I assume you use windows, so here is an answer how to install pip on windows:
how-do-i-install-pip-on-windows
On Linux you could just type:
sudo apt install python-pip

import error when trying to use pip command in ubuntu terminal

I just installed pip with ubuntu onto my laptop. Whenever I try to use pip in the terminal, I keep getting this error:
lopuj#lopuj-Dell-System-XPS-L502X:~$ pip
Traceback (most recent call last):
File "/usr/local/bin/pip", line 9, in <module>
load_entry_point('pip==1.4.1', 'console_scripts', 'pip')()
File "/usr/local/lib/python3.4/dist-packages/setuptools-1.1.5-py3.4.egg/pkg_resources.py", line 357, in load_entry_point
def get_entry_info(dist, group, name):
File "/usr/local/lib/python3.4/dist-packages/setuptools-1.1.5-py3.4.egg/pkg_resources.py", line 2394, in load_entry_point
break
File "/usr/local/lib/python3.4/dist-packages/setuptools-1.1.5-py3.4.egg/pkg_resources.py", line 2108, in load
name = some.module:some.attr [extra1,extra2]
ImportError: No module named 'pip'
lopuj#lopuj-Dell-System-XPS-L502X:~$ ^C
lopuj#lopuj-Dell-System-XPS-L502X:~$
How can I stop this from happening so i can just type in commands like 'pip install Django==1.7.1'?
Your referencing
usr/local
but pip is installed at
usr/lib
Check your installation. I would reinstall using esay_install and then open/close terminal.

Categories

Resources