I'm trying to look around on this issue but so far nothing I've found has fixed it. I am not that familiar with Python and I'm working with someone else's script. I am on Windows 10 (64-bit).
Executing this command: pip install mysql-python
And getting this error:
Traceback (most recent call last):
File "C:\Python27\Lib\runpy.py", line 162, in _run_module_as_main
"__main__", fname, loader, pkg_name)
File "C:\Python27\Lib\runpy.py", line 72, in _run_code
exec code in run_globals
File "C:\Python27\Scripts\pip.exe\__main__.py", line 5, in <module>
File "C:\Python27\lib\site-packages\pip\__init__.py", line 15, in <module>
from pip.vcs import git, mercurial, subversion, bazaar # noqa
File "C:\Python27\lib\site-packages\pip\vcs\mercurial.py", line 9, in <module>
from pip.download import path_to_url
File "C:\Python27\lib\site-packages\pip\download.py", line 38, in <module>
from pip._vendor import requests, six
File "C:\Python27\lib\site-packages\pip\_vendor\requests\__init__.py", line 58, in <module>
from . import utils
File "C:\Python27\lib\site-packages\pip\_vendor\requests\utils.py", line 26, in <module>
from .compat import parse_http_list as _parse_list_header
File "C:\Python27\lib\site-packages\pip\_vendor\requests\compat.py", line 7, in <module>
from .packages import chardet
File "C:\Python27\lib\site-packages\pip\_vendor\requests\packages\__init__.py", line 29, in <module>
import urllib3
ImportError: No module named urllib3
The python module that you are trying to install will probably require you to compile it which makes the task much harder for a newbie.
Instead, I would recommend you to use a pure-python module like https://github.com/PyMySQL/PyMySQL -- which is much easier to install because you do not have to compile it.
Usually I recommend anyone that is trying to work with databases in Python to use SQLAlchemy, mainly because this allows you to use a single interface when you deal with the database, one that does not depends on the database-driver being used.
Read the answer from
python3 sqlalchemy pymysql connect string in order to get an idea about how to use pymysql via sqlalchemy.
wget https://pypi.python.org/packages/3b/f0/e763169124e3f5db0926bc3dbfcd580a105f9ca44cf5d8e6c7a803c9f6b5/urllib3-1.16.tar.gz#md5=fcaab1c5385c57deeb7053d3d7d81d59
tar xvf urllib3-1.16.tar.gz && cd urllib3-1.1
python setup.py install
Related
I am quite new to programming so don't be mad if I get something wrong.
I updated pip to its latest version (something like 21.x.x) and I tried to install the Detectron2 Git repo.
But anything related with pip (even when checking its version) I get the following Traceback:
Traceback (most recent call last):
File "/Users/user/opt/anaconda3/bin/pip", line 7, in <module>
from pip._internal.cli.main import main
File "/Users/user/opt/anaconda3/lib/python3.8/site-packages/pip/_internal/cli/main.py", line 8, in <module>
from pip._internal.cli.autocompletion import autocomplete
File "/Users/user/opt/anaconda3/lib/python3.8/site-packages/pip/_internal/cli/autocompletion.py", line 9, in <module>
from pip._internal.cli.main_parser import create_main_parser
File "/Users/user/opt/anaconda3/lib/python3.8/site-packages/pip/_internal/cli/main_parser.py", line 7, in <module>
from pip._internal.cli import cmdoptions
File "/Users/user/opt/anaconda3/lib/python3.8/site-packages/pip/_internal/cli/cmdoptions.py", line 22, in <module>
from pip._internal.cli.progress_bars import BAR_TYPES
File "/Users/user/opt/anaconda3/lib/python3.8/site-packages/pip/_internal/cli/progress_bars.py", line 9, in <module>
from pip._internal.utils.logging import get_indentation
File "/Users/user/opt/anaconda3/lib/python3.8/site-packages/pip/_internal/utils/logging.py", line 14, in <module>
from pip._internal.utils.misc import ensure_dir
File "/Users/user/opt/anaconda3/lib/python3.8/site-packages/pip/_internal/utils/misc.py", line 29, in <module>
from pip._internal.locations import get_major_minor_version, site_packages, user_site
File "/Users/user/opt/anaconda3/lib/python3.8/site-packages/pip/_internal/locations/__init__.py", line 9, in <module>
from . import _distutils, _sysconfig
File "/Users/user/opt/anaconda3/lib/python3.8/site-packages/pip/_internal/locations/_sysconfig.py", line 8, in <module>
from pip._internal.exceptions import InvalidSchemeCombination, UserInstallationInvalid
ImportError: cannot import name 'InvalidSchemeCombination' from 'pip._internal.exceptions' (/Users/user/opt/anaconda3/lib/python3.8/site-packages/pip/_internal/exceptions.py)
Is there a solution for my problem?
I also tried downgrading to an earlier version but as I said any comment with pip inside gives me this Traceback...
If anyone out there can help me I would be so grateful!
I was having the same error after upgrading to pip 20.x.x, there is a solution on GitHub(https://github.com/pypa/pip/issues/5599) which helped me to understand the problem, but it doesn't help me. So let's come to the solution
Solution
Manually remove or delete the pip file and pip-20.2.4-py3.7.egg-info file from the directory, which in your case is located in /Users/user/opt/anaconda3/lib/python3.7/site-packages and for some it's in /home/user/anaconda3/lib/python3.7/site-packages.
Now use conda remove --force pip to completely remove pip from your system.
Finally, use conda install -c anaconda pip to install pip in your anaconda environment.
For me, it worked, hope it will work for you too
best of luck
I'm trying to use mayavi in python to visualize a pointcloud, and cannot resolve this error. I'm sure it is an easy pip install, but I am unsure of the command. Any help is much appreciated! Thanks!
BTW, I am running Ubuntu 18.04 and have tried installing scipy as mentioned here: Python import error "getfullargspec". I have also ran pip install traitsui. Additionally, I have rebooted my system.
Update:
After further digging, it appears that it may be an issue with Python versions. I was able to get it to run with Python3, but not Python 2.7 (I need it to work with python 2). I have also tried modifying the code within handler.py to getargspec instead of getfullargspec. I was given an error about trait_factory by doing this
Here is the entire printout:
Traceback (most recent call last):
File "mayavi_test.py", line 3, in <module>
from mayavi import mlab
File "/home/user/.local/lib/python2.7/site-packages/mayavi/mlab.py", line 16, in <module>
from mayavi.tools.camera import view, roll, yaw, pitch, move
File "/home/user/.local/lib/python2.7/site-packages/mayavi/tools/camera.py", line 24, in <module>
from .engine_manager import get_engine
File "/home/user/.local/lib/python2.7/site-packages/mayavi/tools/engine_manager.py", line 12, in <module>
from mayavi.preferences.api import preference_manager
File "/home/user/.local/lib/python2.7/site-packages/mayavi/preferences/api.py", line 4, in <module>
from .preference_manager import preference_manager
File "/home/user/.local/lib/python2.7/site-packages/mayavi/preferences/preference_manager.py", line 29, in <module>
from traitsui.api import View, Group, Item
File "/home/user/.local/lib/python2.7/site-packages/traitsui/api.py", line 37, in <module>
from .editors.api import (
File "/home/user/.local/lib/python2.7/site-packages/traitsui/editors/__init__.py", line 26, in <module>
from .api import (
File "/home/user/.local/lib/python2.7/site-packages/traitsui/editors/api.py", line 6, in <module>
from .array_editor import ArrayEditor
File "/home/user/.local/lib/python2.7/site-packages/traitsui/editors/array_editor.py", line 34, in <module>
from ..view import View
File "/home/user/.local/lib/python2.7/site-packages/traitsui/view.py", line 41, in <module>
from .ui import UI
File "/home/user/.local/lib/python2.7/site-packages/traitsui/ui.py", line 51, in <module>
from .handler import Handler, ViewHandler
File "/home/user/.local/lib/python2.7/site-packages/traitsui/handler.py", line 27, in <module>
from inspect import getfullargspec
ImportError: cannot import name getfullargspec
The solution for this problem was to use older packages. Not all of the dependencies such as traitsui are compatible with Python 2.7. Even though an older version of mayavi was installed, the dependencies that are installed automatically are not compatible (they only support Python 3).
Here are the versions that work well together for me:
mayavi==4.6.2
traitsui==6.1.3
traits==5.2.0
numpy==1.17.4
pyface==6.1.2
To install a specific version, just run sudo pip install packageName==#.#.#
I'm trying to start a flask application, with flask run, (which was working fine before I installed Anaconda), and I'm getting the following stack trace
Traceback (most recent call last):
File "C:\Users\Rodrigo\Anaconda3\lib\runpy.py", line 193, in _run_module_as_main
"__main__", mod_spec)
File "C:\Users\Rodrigo\Anaconda3\lib\runpy.py", line 85, in _run_code
exec(code, run_globals)
File "C:\Users\Rodrigo\Documents\Project1\frontEnd\venv\Scripts\flask.exe\__main__.py", line 5, in <module>
File "C:\Users\Rodrigo\Documents\Project1\frontEnd\venv\lib\site-packages\flask\__init__.py", line 19, in <module>
from jinja2 import Markup, escape
File "C:\Users\Rodrigo\Documents\Project1\frontEnd\venv\lib\site-packages\jinja2\__init__.py", line 82, in <module>
_patch_async()
File "C:\Users\Rodrigo\Documents\Project1\frontEnd\venv\lib\site-packages\jinja2\__init__.py", line 78, in _patch_async
from jinja2.asyncsupport import patch_all
File "C:\Users\Rodrigo\Documents\Project1\frontEnd\venv\lib\site-packages\jinja2\asyncsupport.py", line 13, in <module>
import asyncio
File "C:\Users\Rodrigo\Anaconda3\lib\asyncio\__init__.py", line 8, in <module>
from .base_events import *
File "C:\Users\Rodrigo\Anaconda3\lib\asyncio\base_events.py", line 39, in <module>
from . import events
File "C:\Users\Rodrigo\Anaconda3\lib\asyncio\events.py", line 14, in <module>
import contextvars
File "C:\Users\Rodrigo\Anaconda3\lib\contextvars.py", line 1, in <module>
from _contextvars import Context, ContextVar, Token, copy_context
ModuleNotFoundError: No module named '_contextvars'
The Python version at the system level is 3.7.3
The Python version at venv level is 3.7.0
I've already tried to install contextvars, but it only upgraded an older version and did not fix the problem. In both system level and venv level contextvars requisite is already satisfied.
I'm running this on Windows 10.
Any idea on what can be causing this?
I have the same issue when using python 3.7.2 on Windows 7.
This is a known bug and should be resolved.
https://bugs.python.org/issue34691
Updating to python 3.7.3 resolved the issue (for me).
Try to update your venv level to 3.7.3
A few days ago I started getting the following error when using pip (1,2 or 3) to install.
*
Traceback (most recent call last): File "/home/c4pta1n/.local/bin/pip", line 7, in <module>
from pip._internal import main File "/home/c4pta1n/.local/lib/python2.7/site-packages/pip/_internal/__init__.py", line 42, in <module>
from pip._internal import cmdoptions File "/home/c4pta1n/.local/lib/python2.7/site-packages/pip/_internal/cmdoptions.py", line 16, in <module>
from pip._internal.index import ( File "/home/c4pta1n/.local/lib/python2.7/site-packages/pip/_internal/index.py", line 15, in <module>
from pip._vendor import html5lib, requests, six File "/home/c4pta1n/.local/lib/python2.7/site-packages/pip/_vendor/requests/__init__.py", line 86, in <module>
from pip._vendor.urllib3.contrib import pyopenssl File "/home/c4pta1n/.local/lib/python2.7/site-packages/pip/_vendor/urllib3/contrib/pyopenssl.py", line 46, in <module>
import OpenSSL.SSL File "/usr/local/lib/python2.7/dist-packages/OpenSSL/__init__.py", line 8, in <module>
from OpenSSL import rand, crypto, SSL File "/usr/local/lib/python2.7/dist-packages/OpenSSL/crypto.py", line 13, in <module>
from cryptography.hazmat.primitives.asymmetric import dsa, rsa File "/usr/local/lib/python2.7/dist-packages/cryptography/hazmat/primitives/asymmetric/__init__.py", line 12, in <module>
#six.add_metaclass(abc.ABCMeta) AttributeError: 'module' object has no attribute 'add_metaclass'
*
pip3 install pip --ignore-installed six
Traceback (most recent call last):
File "/usr/local/bin/pip3", line 11, in <module>
load_entry_point('pip==10.0.1', 'console_scripts', 'pip3')()
File "/usr/local/lib/python2.7/dist-packages/pkg_resources/__init__.py", line 476, in load_entry_point
return get_distribution(dist).load_entry_point(group, name)
File "/usr/local/lib/python2.7/dist-packages/pkg_resources/__init__.py", line 2700, in load_entry_point
return ep.load()
File "/usr/local/lib/python2.7/dist-packages/pkg_resources/__init__.py", line 2318, in load
return self.resolve()
File "/usr/local/lib/python2.7/dist-packages/pkg_resources/__init__.py", line 2324, in resolve
module = __import__(self.module_name, fromlist=['__name__'], level=0)
File "/usr/local/lib/python2.7/dist-packages/pip/_internal/__init__.py", line 42, in <module>
from pip._internal import cmdoptions
File "/usr/local/lib/python2.7/dist-packages/pip/_internal/cmdoptions.py", line 16, in <module>
from pip._internal.index import (
File "/usr/local/lib/python2.7/dist-packages/pip/_internal/index.py", line 15, in <module>
from pip._vendor import html5lib, requests, six
File "/usr/local/lib/python2.7/dist-packages/pip/_vendor/requests/__init__.py", line 86, in <module>
from pip._vendor.urllib3.contrib import pyopenssl
File "/usr/local/lib/python2.7/dist-packages/pip/_vendor/urllib3/contrib/pyopenssl.py", line 46, in <module>
import OpenSSL.SSL
File "/usr/local/lib/python2.7/dist-packages/OpenSSL/__init__.py", line 8, in <module>
from OpenSSL import rand, crypto, SSL
File "/usr/local/lib/python2.7/dist-packages/OpenSSL/crypto.py", line 13, in <module>
from cryptography.hazmat.primitives.asymmetric import dsa, rsa
File "/usr/local/lib/python2.7/dist-packages/cryptography/hazmat/primitives/asymmetric/__init__.py", line 12, in <module>
#six.add_metaclass(abc.ABCMeta)
AttributeError: 'module' object has no attribute 'add_metaclass'
I have been researching and trying to troubleshoot this issue and I have not been able to narrow down the issue.
Just prior to noticing this issue I had updated my debian system using the standard repository and had no issues of note, I had also updated a few pip modules using pip3 install --update, I believe the modules I had updated were scapy and requests
I am unable to use pip for any command that I have tried, even "pip list" or any version of pip through 3.6.
I have uninstalled and reinstalled pip, virtualenv, and tried to manually remove the six.add_metaclass-1.0* folder from my distutils folder.
Nothing I have tried has created any change that I can see and I am not able to narrow down that any issue that I see written about is indeed similar or related to this specific issue.
I am hoping to find help to narrow this problem down further, correct it or be pointed in the direction of any information that could help me.
six 1.3.0 doesn't have add_metaclass. It was released in 2013 year. Really time to upgrade it.
I found the answer to my issue. Apparently some linux versions have specific versions of pip and six that have to be installed through the distro package manager directly in order to work. There are some nuanced changes in how Debian makes use of pip, especially regarding updates, and they have coded these changes in to their package manager and not to pip. When I recompiled Python I had uninstalled the entire python framework and I went to the source url's to recombine python and to download pip and any other dependencies. I figured since I was installing directly from the source that it would be fine... If you are using CentOS, Debian,Redhat and maybe others, then you must install pip from the package manager that is managed by your distro in order to avoid running into this error somewhere down the line.
I am using python 3.4. I am able to run my python script without any problem.
But While running my freezed python script , following error have appeared.
I am able to freeze my script successfully too with cx_freeze.
C:\Program Files (x86)\utils>utils.exe
Traceback (most recent call last):
File "C:\Python34\lib\site-packages\requests\packages\__init__.py", line 27, i
n <module>
from . import urllib3
File "C:\Python34\lib\site-packages\requests\packages\urllib3\__init__.py", line 8, in <module>
from .connectionpool import (
File "C:\Python34\lib\site-packages\requests\packages\urllib3\connectionpool.py", line 28, in <module>
from .packages.six.moves.queue import LifoQueue, Empty, Full
File "C:\Python34\lib\site-packages\requests\packages\urllib3\packages\six.py", line 203, in load_module
mod = mod._resolve()
File "C:\Python34\lib\site-packages\requests\packages\urllib3\packages\six.py", line 115, in _resolve
return _import_module(self.mod)
File "C:\Python34\lib\site-packages\requests\packages\urllib3\packages\six.py", line 82, in _import_module
__import__(name)
ImportError: No module named 'queue'
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "C:\Python34\lib\site-packages\cx_Freeze\initscripts\__startup__.py", line 12, in <module>
__import__(name + "__init__")
File "C:\Python34\lib\site-packages\cx_Freeze\initscripts\Console.py", line 21, in <module>
scriptModule = __import__(moduleName)
File "utils.py", line 3, in <module>
File "C:\Python34\lib\site-packages\requests\__init__.py", line 63, in <module>
from . import utils
File "C:\Python34\lib\site-packages\requests\utils.py", line 24, in <module>
from ._internal_utils import to_native_string
File "C:\Python34\lib\site-packages\requests\_internal_utils.py", line 11, in <module>
from .compat import is_py2, builtin_str
File "C:\Python34\lib\site-packages\requests\compat.py", line 11, in <module>
from .packages import chardet
File "C:\Python34\lib\site-packages\requests\packages\__init__.py", line 29, in <module>
import urllib3
File "C:\Python34\lib\site-packages\urllib3\__init__.py", line 8, in <module>
from .connectionpool import (
File "C:\Python34\lib\site-packages\urllib3\connectionpool.py", line 28, in <module>
from .packages.six.moves.queue import LifoQueue, Empty, Full
File "C:\Python34\lib\site-packages\urllib3\packages\six.py", line 203, in load_module
mod = mod._resolve()
File "C:\Python34\lib\site-packages\urllib3\packages\six.py", line 115, in _resolve
return _import_module(self.mod)
File "C:\Python34\lib\site-packages\urllib3\packages\six.py", line 82, in _import_module
__import__(name)
ImportError: No module named 'queue'
Even tried installing package 'six' with no help.
My setup.py is
from cx_Freeze import setup, Executable
import requests.certs
setup(
name = "utils" ,
version = "0.1" ,
description = " utils for accounts" ,
executables = [Executable("utils.py")],
options = {"build_exe": {"packages": ["urllib", "requests"],"include_files":[(requests.certs.where(),'cacert.pem')]}},
)
script imports following module
import requests
import urllib.request
import uuid
import json
import http.client
from xml.dom import minidom
Any help will be highly appreciated. please see me as novice in python
I had the same issues running on Ubuntu with Python 3.5. It seems that cx_freeze has problems with libraries that import other files or something like that.
Importing Queue together with requests worked for me, so:
import requests
from multiprocessing import Queue
And I don't think specifying urllib in "packages": ["urllib", "requests"] is necessary.
There are Several options based on project packages:
Method1:
Answer: I solve the problem my issue was I had file named queue.py in the same
directory
Method2:
Queue is in the multiprocessing module so:
from multiprocessing import Queue
Method3:
Updating pip from 1.5.6 to 8.1.2
`sudo python -m pip install -U pip`
Reboot system (don't know if necessary, but only after reboot new version of pip was listed)
Method4:
from six.moves.queue import Queue //I don't know how u import six package
In setup.py, options={"build_exe": {"packages": ["multiprocessing"]}} can also do the trick.
In addition to
from multiprocessing import Queue
I rolled back to the older version of cx_freeze:
pip install cx-freeze==4.3.3
Besides, the "requests" library complained on absence of "urllib3" module. I upgraded this to requests==2.13.0 and all now works.
I'm using Python 3.4 on Win10. Hope this will help.