I'm having this error for the last 2 days. It seems a problem with python requests library, but I've re-installed it several times with no luck.
Traceback (most recent call last):
File "project-src/bla-blah/manage.py", line 10, in <module>
execute_from_command_line(sys.argv)
File "project-src\env\lib\site-packages\django\core\management\__init__.py", line 385, in execute_from_command_line
utility.execute()
File "project-src\env\lib\site-packages\django\core\management\__init__.py", line 354, in execute
django.setup()
File "project-src\env\lib\site-packages\django\__init__.py", line 21, in setup
apps.populate(settings.INSTALLED_APPS)
File "project-src\env\lib\site-packages\django\apps\registry.py", line 85, in populate
app_config = AppConfig.create(entry)
File "project-src\env\lib\site-packages\django\apps\config.py", line 112, in create
mod = import_module(mod_path)
File "C:\Python34\lib\importlib\__init__.py", line 109, in import_module
return _bootstrap._gcd_import(name[level:], package, level)
File "<frozen importlib._bootstrap>", line 2254, in _gcd_import
File "<frozen importlib._bootstrap>", line 2237, in _find_and_load
File "<frozen importlib._bootstrap>", line 2226, in _find_and_load_unlocked
File "<frozen importlib._bootstrap>", line 1200, in _load_unlocked
File "<frozen importlib._bootstrap>", line 1129, in _exec
File "<frozen importlib._bootstrap>", line 1471, in exec_module
File "<frozen importlib._bootstrap>", line 321, in _call_with_frames_removed
File "project-src\env\lib\site-packages\social\apps\django_app\__init__.py", line 14, in <module>
from social.apps.django_app.utils import load_strategy
File "project-src\env\lib\site-packages\social\apps\django_app\utils.py", line 12, in <module>
from social.backends.utils import get_backend
File "project-src\env\lib\site-packages\social\backends\utils.py", line 2, in <module>
from social.backends.base import BaseAuth
File "project-src\env\lib\site-packages\social\backends\base.py", line 1, in <module>
from requests import request, ConnectionError
File "project-src\env\lib\site-packages\requests\__init__.py", line 58, in <module>
from . import utils
File "project-src\env\lib\site-packages\requests\utils.py", line 24, in <module>
from . import certs
ImportError: cannot import name 'certs'
Maybe it's a problem with Windows 7 update from 2 days ago, because is the only thing that has changed in the last few days.
By the way, I'm using python 3.4 with virtualenv, PyCharm 3.4.1 IDE and Win7.
Inside certs.py there is the code that has the problem (last line):
try:
from certifi import where
except ImportError:
def where():
"""Return the preferred certificate bundle."""
# vendored bundle inside Requests
return os.path.join(os.path.dirname(__file__), 'cacert.pem')
This worked for me (re-install requests library):
pip uninstall requests
pip install requests
I had also the same problem last week on my Mac (Sierra). Besides, the certs.py module exists, which means that's a problem somehow related to the OS and not to Python itself. In my case, it was a problem of the max files limits, So just increase it with ulimit 200000 200000
In case you're wondering what happened with this problem... I re-installed the operating system, downloaded the git project again, re-configured the python virtualenv and 'magically' it worked. So I'm sure there was a miss-configuration somewhere, but it wasn't requests library problem.
If you have the same problem, I encourage you to install a fresh environment.
Related
We did not update any lib or new lib added. During deployment of Django web application, got the following error:
Traceback (most recent call last):
File "/usr/local/lib/python3.7/site-packages/celery/fixups/django.py", line 118, in django_setup
django.setup()
File "/usr/local/lib/python3.7/site-packages/django/__init__.py", line 24, in setup
apps.populate(settings.INSTALLED_APPS)
File "/usr/local/lib/python3.7/site-packages/django/apps/registry.py", line 91, in populate
app_config = AppConfig.create(entry)
File "/usr/local/lib/python3.7/site-packages/django/apps/config.py", line 116, in create
mod = import_module(mod_path)
File "/usr/local/lib/python3.7/importlib/__init__.py", line 127, in import_module
return _bootstrap._gcd_import(name[level:], package, level)
File "<frozen importlib._bootstrap>", line 1006, in _gcd_import
File "<frozen importlib._bootstrap>", line 983, in _find_and_load
File "<frozen importlib._bootstrap>", line 967, in _find_and_load_unlocked
File "<frozen importlib._bootstrap>", line 677, in _load_unlocked
File "<frozen importlib._bootstrap_external>", line 728, in exec_module
File "<frozen importlib._bootstrap>", line 219, in _call_with_frames_removed
File "/usr/local/lib/python3.7/site-packages/channels/apps.py", line 4, in <module>
import daphne.server
File "/usr/local/lib/python3.7/site-packages/daphne/server.py", line 5, in <module>
from twisted.internet import asyncioreactor # isort:skip
File "/usr/local/lib/python3.7/site-packages/twisted/internet/asyncioreactor.py", line 19, in <module>
from twisted.internet.posixbase import (
File "/usr/local/lib/python3.7/site-packages/twisted/internet/posixbase.py", line 16, in <module>
from twisted.internet import error, tcp, udp
File "/usr/local/lib/python3.7/site-packages/twisted/internet/tcp.py", line 99, in <module>
from twisted.internet import abstract, address, base, error, fdesc, main
File "/usr/local/lib/python3.7/site-packages/twisted/internet/base.py", line 34, in <module>
from twisted.internet import abstract, defer, error, fdesc, main, threads
File "/usr/local/lib/python3.7/site-packages/twisted/internet/defer.py", line 42, in <module>
from typing_extensions import Literal, ParamSpec, Protocol
ImportError: cannot import name 'ParamSpec' from 'typing_extensions' (/usr/local/lib/python3.7/site-packages/typing_extensions.py)
This seems to be involving typing_extensions from Python package.
So, it turned out that I did not update any library. But, in requirements.txt, only channels library specific version was mentioned so while deployment the version of channels stayed the same. Meanwhile twisted library is a 3rd level dependency and not directly mentioned in my requirements.txt.
So twisted library got updated on its own without a warning as it's latest version 22.10.0 released. During deployment it led to above error straight away making us wonder who updated it.
To resolve this issue, we tried using the updated the version of twisted but it led to another error even version 4.4.0 and 4.0.0
In the end, we took all the libs using pip freeze from stable running Docker container (virtual env, in your case maybe) and added all the required dependencies in the requirements.txt. This will keep away the unexpected library upgraded happening silently in the background.
I have been using PyQt6 for a while without a problem. Now I'm trying to do the exercises from a textbook, using pyqtgraph. It does not seem to come bundled with PyQt6 because the import statement failed. I tried installing it with:
pip install pyqtgraph
I tried various combinations of sudo, pip, pip3 (pip points to pip3), python/python3.8/python3.9 -m pip install pyqtgraph (python links to python3). I forced a reinstall of pip from a curl and deleted old site-package versions from .local. I even did a git clone pyqtgraph and tried to build it from scratch. Nothing worked. I always get the same error:
Traceback (most recent call last):
File "/home/richard/.local/bin/pip", line 8, in <module>
sys.exit(main())
File "/home/richard/.local/lib/python3.9/site-packages/pip/_internal/cli/main.py", line 68, in main
command = create_command(cmd_name, isolated=("--isolated" in cmd_args))
File "/home/richard/.local/lib/python3.9/site-packages/pip/_internal/commands/__init__.py", line 109, in create_command
module = importlib.import_module(module_path)
File "/usr/lib/python3.9/importlib/__init__.py", line 127, in import_module
return _bootstrap._gcd_import(name[level:], package, level)
File "<frozen importlib._bootstrap>", line 1030, in _gcd_import
File "<frozen importlib._bootstrap>", line 1007, in _find_and_load
File "<frozen importlib._bootstrap>", line 986, in _find_and_load_unlocked
File "<frozen importlib._bootstrap>", line 680, in _load_unlocked
File "<frozen importlib._bootstrap_external>", line 850, in exec_module
File "<frozen importlib._bootstrap>", line 228, in _call_with_frames_removed
File "/home/richard/.local/lib/python3.9/site-packages/pip/_internal/commands/install.py", line 14, in <module>
from pip._internal.cli.req_command import (
File "/home/richard/.local/lib/python3.9/site-packages/pip/_internal/cli/req_command.py", line 20, in <module>
from pip._internal.index.collector import LinkCollector
File "/home/richard/.local/lib/python3.9/site-packages/pip/_internal/index/collector.py", line 42, in <module>
from pip._internal.network.session import PipSession
File "/home/richard/.local/lib/python3.9/site-packages/pip/_internal/network/session.py", line 31, in <module>
from pip._internal.network.auth import MultiDomainBasicAuth
File "/home/richard/.local/lib/python3.9/site-packages/pip/_internal/network/auth.py", line 22, in <module>
from pip._internal.vcs.versioncontrol import AuthInfo
File "/home/richard/.local/lib/python3.9/site-packages/pip/_internal/vcs/__init__.py", line 7, in <module>
import pip._internal.vcs.mercurial
ModuleNotFoundError: No module named 'pip._internal.vcs.mercurial'
I also reinstalled mercurial.
I can't find any posts on pip._internal.vcs.mercurial, although there are plenty of posts on missing pip._internal, none of which helps.
I am getting the following error when trying to launch shell_plus after installing django_extensions. Here are the steps i followed
1-Installed django_extensions using
pip install django_extensions
2-Added django_extensions to installed apps
Then I get the following error
$ ./manage.py shell_plus
Traceback (most recent call last):
File "./manage.py", line 15, in <module>
execute_from_command_line(sys.argv)
File "/Users/admin/Development/project/virtual/lib/python3.5/site-packages/django/core/management/__init__.py", line 371, in execute_from_command_line
utility.execute()
File "/Users/admin/Development/project/virtual/lib/python3.5/site-packages/django/core/management/__init__.py", line 365, in execute
self.fetch_command(subcommand).run_from_argv(self.argv)
File "/Users/admin/Development/project/virtual/lib/python3.5/site-packages/django/core/management/__init__.py", line 216, in fetch_command
klass = load_command_class(app_name, subcommand)
File "/Users/admin/Development/project/virtual/lib/python3.5/site-packages/django/core/management/__init__.py", line 36, in load_command_class
module = import_module('%s.management.commands.%s' % (app_name, name))
File "/Library/Frameworks/Python.framework/Versions/3.5/lib/python3.5/importlib/__init__.py", line 126, in import_module
return _bootstrap._gcd_import(name[level:], package, level)
File "<frozen importlib._bootstrap>", line 986, in _gcd_import
File "<frozen importlib._bootstrap>", line 969, in _find_and_load
File "<frozen importlib._bootstrap>", line 958, in _find_and_load_unlocked
File "<frozen importlib._bootstrap>", line 673, in _load_unlocked
File "<frozen importlib._bootstrap_external>", line 662, in exec_module
File "<frozen importlib._bootstrap>", line 222, in _call_with_frames_removed
File "/Users/admin/Development/project/virtual/lib/python3.5/site-packages/django_extensions/management/commands/shell_plus.py", line 14, in <module>
from django_extensions.management.shells import import_objects
File "/Users/admin/Development/project/virtual/lib/python3.5/site-packages/django_extensions/management/shells.py", line 5, in <module>
from typing import ( # NOQA
ImportError: cannot import name 'Type'
Any suggestions on what might be going wrong ?
Python 3.5 comes with its own version of typing module. What is most likely happening is that you have the other typing module specified in your requirements (the one that doesn't include Type class) and its getting picked up by django_extensions instead of the native Python one. Check your installed modules, or try running:
pip uninstall typing
I am trying to install readthedocs in local system (Ubuntu 14.04 ) in python3 virtual env from the instructions given in this link
When I ran pip3 install -r requirements.txt , I got an error for Distutils2 . I removed that dependency as the distutils2 is no longer supported and assumed setuptools would suffice.
Running this command python manage.py migrate gave the below error :
Traceback (most recent call last):
File "manage.py", line 11, in <module>
execute_from_command_line(sys.argv)
File "/home/username/read_the_docs_env/lib/python3.4/site-packages/django/core/management/__init__.py", line 338, in execute_from_command_line
utility.execute()
File "/home/username/read_the_docs_env/lib/python3.4/site-packages/django/core/management/__init__.py", line 312, in execute
django.setup()
File "/home/username/read_the_docs_env/lib/python3.4/site-packages/django/__init__.py", line 18, in setup
apps.populate(settings.INSTALLED_APPS)
File "/home/username/read_the_docs_env/lib/python3.4/site-packages/django/apps/registry.py", line 115, in populate
app_config.ready()
File "/home/username/read_the_docs_env/lib/python3.4/site-packages/django/contrib/admin/apps.py", line 22, in ready
self.module.autodiscover()
File "/home/username/read_the_docs_env/lib/python3.4/site-packages/django/contrib/admin/__init__.py", line 24, in autodiscover
autodiscover_modules('admin', register_to=site)
File "/home/username/read_the_docs_env/lib/python3.4/site-packages/django/utils/module_loading.py", line 74, in autodiscover_modules
import_module('%s.%s' % (app_config.name, module_to_search))
File "/home/username/read_the_docs_env/lib/python3.4/importlib/__init__.py", line 109, in import_module
return _bootstrap._gcd_import(name[level:], package, level)
File "<frozen importlib._bootstrap>", line 2254, in _gcd_import
File "<frozen importlib._bootstrap>", line 2237, in _find_and_load
File "<frozen importlib._bootstrap>", line 2226, in _find_and_load_unlocked
File "<frozen importlib._bootstrap>", line 1200, in _load_unlocked
File "<frozen importlib._bootstrap>", line 1129, in _exec
File "<frozen importlib._bootstrap>", line 1471, in exec_module
File "<frozen importlib._bootstrap>", line 321, in _call_with_frames_removed
File "/home/username/Desktop/CurrentProjects/read_the_docs/checkouts/readthedocs.org/readthedocs/core/admin.py", line 10, in <module>
from readthedocs.core.views import SendEmailView
File "/home/username/Desktop/CurrentProjects/read_the_docs/checkouts/readthedocs.org/readthedocs/core/views/__init__.py", line 26, in <module>
from readthedocs.projects.tasks import remove_dir
File "/home/username/Desktop/CurrentProjects/read_the_docs/checkouts/readthedocs.org/readthedocs/projects/tasks.py", line 493
print "Sync Versions Exception: %s" % e.message
^
SyntaxError: Missing parentheses in call to 'print'
I understand from the above stacktrace that the code is in python2 and so print statement is different in python3 .
Does this mean that I have to install readthedocs in python2 virtualenv ?
Can't we host the docs of python3 projects in readthedocs in-house server ?
The read the docs code does not support Python 3 yet. The installation instructions explicitly say to use Python 2.7:
First, obtain Python 2.7 and virtualenv
However, it should still be possible to use your read the docs installation to host docs for Python 3 projects, since the instructions then say:
If you plan to import Python 3 project to your RTD then you’ll need to install Python 3 with virtualenv in your system as well.
Question title says it all. I'm not a Python expert, not sure where to go from here. I tried everything I could think of.
I'm using pip3 and python3 with Django 1.8.
Following instructions from https://github.com/omab/python-social-auth I did sudo pip3 install python-social-auth and all the dependencies.
Shell output:
$ python3 manage.py shell
Traceback (most recent call last):
File "./manage.py", line 10, in <module>
execute_from_command_line(sys.argv)
File "/usr/local/lib/python3.4/dist-packages/django/core/management/__init__.py", line 338, in execute_from_command_line
utility.execute()
File "/usr/local/lib/python3.4/dist-packages/django/core/management/__init__.py", line 312, in execute
django.setup()
File "/usr/local/lib/python3.4/dist-packages/django/__init__.py", line 18, in setup
apps.populate(settings.INSTALLED_APPS)
File "/usr/local/lib/python3.4/dist-packages/django/apps/registry.py", line 108, in populate
app_config.import_models(all_models)
File "/usr/local/lib/python3.4/dist-packages/django/apps/config.py", line 198, in import_models
self.models_module = import_module(models_module_name)
File "/usr/lib/python3.4/importlib/__init__.py", line 109, in import_module
return _bootstrap._gcd_import(name[level:], package, level)
File "<frozen importlib._bootstrap>", line 2254, in _gcd_import
File "<frozen importlib._bootstrap>", line 2237, in _find_and_load
File "<frozen importlib._bootstrap>", line 2226, in _find_and_load_unlocked
File "<frozen importlib._bootstrap>", line 1200, in _load_unlocked
File "<frozen importlib._bootstrap>", line 1129, in _exec
File "<frozen importlib._bootstrap>", line 1471, in exec_module
File "<frozen importlib._bootstrap>", line 321, in _call_with_frames_removed
File "/usr/local/lib/python3.4/dist-packages/social/apps/django_app/default/models.py", line 8, in <module>
from social.utils import setting_name
File "/usr/local/lib/python3.4/dist-packages/social/utils.py", line 13, in <module>
from requests.packages.urllib3.poolmanager import PoolManager
ImportError: No module named 'requests.packages'
I'm not sure why the python-social-auth module tries to call requests.packages since that does not seem to exist in the "requests" module.
I solved my own problem.
sudo pip3 install requests --upgrade
Fixed it by upgrading my system's "requests" package.
this question may be getting a bunch of new visitors...
requests.packages has been removed from requests:
https://github.com/kennethreitz/requests/pull/4067
install the vendored libraries separately
pip install urllib3