Installing enum package causes pip to not work - python-2.7

I installed a fresh version of pytodos package using pip (pip install pytodos). It requires enum package to be installed, so it was installed automatically. After this had happened every attempt to do anything with pip, that is to install or uninstall any package, resulted in this error:
_ASN1_TYPE_TO_ENUM = dict((i.value, i) for i in _ASN1Type)
TypeError: 'type' object is not iterable
But when I removed every file that starts with "enum" from ~/.local/lib/python2.7/site-packages:
cd ~/.local/lib/python2.7/site-packages
rm -rf enum*
..., I was able to install and uninstall packages once again. After installing enum package again (pip install enum), everything repeats.
What could be the cause of such behavior?

According to https://github.com/pyca/cryptography/issues/4020 you need to uninstall enum and install enum34 or similar instead. Try:
pip install --upgrade enum34

Finally solution is, drop your pip folder, then again reinstall pip
and other essential dependencies.

Related

Not able to install mysqlclient in Django project

Not able to install mysqlclient in Django project. While running pip giving error as "Microsoft Visual C++ 14.0 Is Required Error".
Tried downloading Microsoft C++ Build Tools
First try upgrading setuptools package through:
pip install --upgrade setuptools
Then try to install again.
If still the issue persists then use the binary-only option for pip.
pip install --only-binary :all: mysqlclient

How to install Pip on a new Ubuntu upgrade

I posted the question below, but none of the answers I was pointed to worked, though they look like they should.
I activated (again) the virtualenv. It still tells me that pip can't be found by apt when doing an 'apt install' command. But here is where I am now, and very confused.
I pointed my directory to "/home/.../q7root/bin/pip" and did an "ls". It shows a sub-directory with pip in it (or, I think, a link to it - I'm not the best at Unix). When I type "which pip" I get the path to this point ('q7root/pip'). bit if I just type "pip" at the CLI I get I get this error:
[![pip error][1]][1]
I have looked at my PATH, and this q7root/bin is the first place to look on the path. And, despite trying mightily with all the references people gave me, pip3 never gets installed.
But even pip is challenged. "which pip" points to this copy in the virtual environment site, but typing "pip" as a command tells me 'No module named pip.'
So pip seems to need more stuff installed (?), or there is some mess. Any advice?
Original Question:
At the suggestion of others working on what was a functional Django project, I upgraded to a more recent version of Ubuntu (18).
However, when I first try to run it it blows up at line 3 of the initial script module when asked to import django as a package.
I tried pip -r requirements.txt, but the system said pip was an unknown package. I dropped down and used apt to load pip onto my machine (sudo apt-get pip), then tried using pip itself (pip update pip) which failed.:
[![Pip load error message][2]][2]
I also tried pip install django, and got this:
[![django not found][3]][3]
I would have thought an OS upgrade would not require re-installing all currently installed packages (seems like a no-brainer to do the work of installing everything that had been installed). But right now I am terribly stuck...obviously, having 'pip' let's you (at least) have a basic CLI tool.
Any advice?
[1]: https://i.stack.imgur.com/OPfgc.png
[2]: https://i.stack.imgur.com/shLOc.png
[3]: https://i.stack.imgur.com/bEhDB.png
It depends on the version of python.
Python 3
sudo apt update
sudo apt install python3-pip
Python 2
sudo apt update
sudo apt install python-pip
How to Install Pip on Ubuntu 18.04
Start with a fresh Ubuntu install. I think you've run too many commands for your current setup to be reproduceable.
Install python3 and python3-venv.
sudo apt update
sudo apt install python3 python3-venv
Use the venv module to create the virtual env.
python3 -m venv myenv
source myenv/bin/activate
You now have access to pip in the venv.
It's OK to upgrade pip in the virtual env, I suggest you don't ever upgrade the system pip otherwise you might hit issues like this.
(myenv) python -m pip --version
(myenv) python -m pip install --upgrade pip
Now you can use pip to install your requirements in the virtual env.
(myenv) python -m pip install -r requirements.txt
In the above commands I've used python -m pip instead of pip. This is the recommended way, as it ensures that you are using the version of pip that matches python.
In the end, this was a state of deep computer confusion. I was already disk-limited so I bought a new computer, and this error did not recur with the same code being used.

Error while running PIP command "no module packaging exists"

I have tried many approaches in resolving this issue but still cannot resolve it can someone please help me.
when I try to run the pip to install any new package it is ending in error with the message no module named packaging.version. This is happening in the __init__.py file where there are import command import packaging.version.
I tried to install the packaging package by using the command pip install packaging even that ended in failure with the same error.
Then I tried to install this package using the apt-get command
sudo apt-get install python-packaging but it ended saying could not find the package.
Finally I tried to update the setuptools package to version 33.1.1 as a part of the previous solutions approaches, but can't do it with pip(same issue as above) so I used the apt-get command
sudo apt-get install setuptools=33.1.1 but it is saying no package with this version found error.
I am out of ideas can someone please help. Appreciate your help.
I believe that your version of pip is obsolete. Try running pip install --upgrade pip.
If you cant do it (still the same error), I'd suggest to reinstall pip.
You can do it with get-pip.py file. Here you can find a quick guide: Installing pip setuptools and wheel.
You may also be able to reinstall it with python -m pip install -U pip.

pip is error,TypeError: __call__() takes exactly 2 arguments (1 given)

system
centos 7.2
Python 2.7.5
install
I install webhook
pip install webhook
### but hava error,then
yum install python-devel -y
## go on,pip doesn't workding
pip
error
Enter the command contain pip.Then
[root#location src]# pip
Traceback (most recent call last):
File "/usr/bin/pip", line 5, in <module>
from pkg_resources import load_entry_point
File "/usr/lib/python2.7/site-packages/pkg_resources/__init__.py", line 72, in <module>
import packaging.requirements
File "/usr/lib/python2.7/site-packages/packaging/requirements.py", line 59, in <module>
MARKER_EXPR = originalTextFor(MARKER_EXPR())("marker")
TypeError: __call__() takes exactly 2 arguments (1 given)
So,what should I do?!
I had the same problem on a fresh virtualenv and apparently this is a conflict between the version requirements for packaging, pip and pyparsing with the new setuptools. What worked for me was to pin down the old one.
pip install setuptools==33.1.1
Update:
As another answer pointed out, pip has already fixed the bug, so you should try upgrading it instead of using the workaround above.
python -m pip install --upgrade --force pip
UPDATE:
Please see the solution lower in this thread by Pedro Werneck instead of this one. It's the correct way to solve the problem.
Preface: I do not recommend this!
This seems to work, but I have no idea what the consequences could be. This is cargo cult programming at its best! I'm only adding it here in case it can help someone in a bind.
I made changes to the file requirements.py where the error occurred. For #hysg, that would be this file:
/usr/lib/python2.7/site-packages/packaging/requirements.py
On me on OS X, it's here:
/Library/Python/2.7/site-packages/packaging/requirements.py
I modified the the offending line by removing the parentheses for the call to MARKER_EXPR, as demonstrated below:
#MARKER_EXPR = originalTextFor(MARKER_EXPR())("marker")
MARKER_EXPR = originalTextFor(MARKER_EXPR)("marker")
And that worked.
Again, please be careful! I don't know what I'm doing and this could potentially cause more harm than good.
this is work well:
python -m pip install --upgrade --force pip
pip install setuptools==33.1.1
This is what worked for me:
pip install setuptools==33.1.1
It downgraded setuptools from 35.0.1 to 33.1.1 and pyparsing 1.5.7 installed!
Use the following command to upgrade pip, which has the bug fixed:
python -m pip install --upgrade --force pip
It worked for me (centos 7, python 2.7).
For more details: GitHub
I applied the fix
pip install setuptools==33.1.1
and it solved the problem for OSX 10.10.5 (Yosemite)
I ran into the same problem on a new virtualenv trying to install. I'm running python 2.7.11 and found the two commands belows solve the versioning problem with setuptools:
This forces a pip upgrade, which has a fix for the bug, but doesn't reinstall setup tools, so I was still running on setuptools version 35.0.1
python -m pip install --upgrade --force pip
This sets setuptools to an older version.
pip install setuptools==33.1.1
After this, I successfully installed my requirements.
None of the other uninstall/reinstall/force answers worked for me, but on OS X 10.10.5 with the system Python 2.7.10, I was able to do:
pip uninstall packaging pip
easy_install pip # this installed pip 1.4.1
pip install --upgrade pip # and this upgraded to the current pip
and I was then able to import pkg_resources without a problem.
Should really learn to stop messing with the system Python…
Actually, I had a problem that OS/system which means root, not sudo, has been the owner of the pip2 package. But after I had executed this command:
sudo apt-get remove python-pip
it worked like a charm.
Noting, of course that I have a debian distribution.
And then I used what Pedro suggested:
sudo pip install setuptools==33.1.1
It worked for me too (centos 7, python 2.7).
python -m pip install --upgrade --force pip
pip install setuptools==33.1.1

Installing MySQL-python for Django

I've just learned how to use virtualenv and I installed Django 1.4.5. I'm assuming that the virtualenv created a clean slate for me to work on so with the Django 1.4.5 installed, I copied all my previous files into the virtualenv environment.
I tried to run the server but I get an error saying "no module named MySQLdb". I think this means that I forgot to install MySQL-python. I tried to install it via
pip install MySQL-python
But I get this error
Downloading/unpacking MySQL-python
Running setup.py egg_info for package MySQL-python
The required version of distribute (>=0.6.28) is not available,
and can't be installed while this script is running. Please
install a more recent version first, using
'easy_install -U distribute'.
(Currently using distribute 0.6.24 (/home/bradford/Development/Django/django_1.4.5/lib/python2.7/site-packages/distribute-0.6.24-py2.7.egg))
Complete output from command python setup.py egg_info:
The required version of distribute (>=0.6.28) is not available,
and can't be installed while this script is running. Please
install a more recent version first, using
'easy_install -U distribute'.
(Currently using distribute 0.6.24 (/home/bradford/Development/Django/django_1.4.5/lib/python2.7/site-packages/distribute-0.6.24-py2.7.egg))
----------------------------------------
Command python setup.py egg_info failed with error code 2 in /home/bradford/Development/Django/django_1.4.5/build/MySQL-python
Not quite sure how to go about fixing this problem =/ any help much appreciated!
I recently had exactly this issue (just not in relation to Django). In my case I am developing on Ubuntu 12.04 using the default pip and distribute versions, which are basically a little out of date for MySQL-python.
Because you are working in an isolated virtualenv, you can safely follow the suggested instruction without affecting your Python installation.
So you can...
workon your_virtualenv #activate your virtualenv, you do use virtualenvwrapper, right?
easy_install -U distribute #update distribute on your virtualenv
pip install MySQL-python #install your package
If for some reason upgrading distribute is not an option, you could try installing an older version of MySQL-python as follows (you'd have to check this version is compatible with your version of Django):
pip install MySQL-python==x.y.z #where x.y.z is the version you want
Spent an hour looking through stackoverflow. Evntually found answer in the other question. This is what saved me:
sudo apt-get install libmysqlclient-dev
mysql_config goes with the package.
When doing in a virtualenv :
pip install MySQL-python
I got
EnvironmentError: mysql_config not found
To install mysql_config, as Artem Fedosov said, first install
sudo apt-get install libmysqlclient-dev
then everything works fine in virtualenv
MySQL driver for Python (mysql-python) needs libmysqlclient-dev. You can get it with:
sudo apt-get update
sudo apt-get install libmysqlclient-dev
If python-dev is not installed, you may have to install it too:
sudo apt-get install python-dev
Now you can install MySQL driver:
pip install mysql-python
Here is a more detailed documentation for MySQL in Django:
http://codex.themedelta.com/how-to-install-django-with-mysql-in-a-virtualenv-on-linux/
I had to do this:
pip install mysql-python
inside the virtualenv
The commands are always run in ubuntu:
easy_install -U distribute
later
sudo apt-get install libmysqlclient-dev
and finally
pip install MySQL-python
The suggested solutions didn't work out for me, because I still got compilation errors after running
`$ sudo apt-get install libmysqlclient-dev`
so I had to run
apt-get install python-dev
Then everything worked fine for me with
apt-get install python-dev
Try this:
Version Python 2.7
MySQL-python package, you should use either MySQL_python‑1.2.5‑cp27‑none‑win32.whl or
MySQL_python‑1.2.5‑cp27‑none‑win_amd64.whl depending on whether you have installed 32-bit or 64-bit Python.
pip install MySQL_python‑1.2.5‑cp27‑none‑win32.whl
if you are using mysqlclient package, then use
mysqlclient‑1.4.6‑cp27‑cp27m‑win32.whl or
mysqlclient‑1.4.6‑cp27‑cp27m‑win_amd64.whl
pip install mysqlclient‑1.4.6‑cp27‑cp27m‑win32.whl
https://www.lfd.uci.edu/~gohlke/pythonlibs/#mysqlclient