Super new to coding and i'm trying to learn Python. I have used Anaconda to manage packages, etc. I typically update Anaconda/conda in cmd with commands such as conda update conda or conda update anaconda
As of late, when using these commands, it comes up with a message: "ImportError: No module named 'Requests.exceptions'" followed by "Import Error: cannot import name 'Session'" Please see below.
Traceback (most recent call last):
File "C:\Program Files\Anaconda3\lib\site-packages\conda\cli\main.py", line 171, in main
activate.main()
File "C:\Program Files\Anaconda3\lib\site-packages\conda\cli\activate.py", line 181, in main
from ..install import symlink_conda
File "C:\Program Files\Anaconda3\lib\site-packages\conda\install.py", line 37, in <module>
from .core.package_cache import rm_fetched # NOQA
File "C:\Program Files\Anaconda3\lib\site-packages\conda\core\package_cache.py", line 9, in <module>
from .path_actions import CacheUrlAction, ExtractPackageAction
File "C:\Program Files\Anaconda3\lib\site-packages\conda\core\path_actions.py", line 33, in <module>
from ..gateways.download import download
File "C:\Program Files\Anaconda3\lib\site-packages\conda\gateways\download.py", line 10, in <module>
from requests.exceptions import ConnectionError, HTTPError, InvalidSchema, SSLError
ImportError: No module named 'requests.exceptions'
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "C:\Program Files\Anaconda3\Scripts\conda-script.py", line 10, in <module>
sys.exit(main())
File "C:\Program Files\Anaconda3\lib\site-packages\conda\cli\main.py", line 179, in main
return handle_exception(e)
File "C:\Program Files\Anaconda3\lib\site-packages\conda\exceptions.py", line 634, in handle_exception
print_unexpected_error_message(e)
File "C:\Program Files\Anaconda3\lib\site-packages\conda\exceptions.py", line 596, in print_unexpected_error_message
stderrlogger.info(get_main_info_str(get_info_dict()))
File "C:\Program Files\Anaconda3\lib\site-packages\conda\cli\main_info.py", line 162, in get_info_dict
from ..connection import user_agent
File "C:\Program Files\Anaconda3\lib\site-packages\conda\connection.py", line 12, in <module>
from requests import Session, __version__ as REQUESTS_VERSION
ImportError: cannot import name 'Session'
I've tried using commands like pip install requests but it says that it has already says "Requirement already satisfied and lists locations where it is installed (i am guessing).
At this point I can't even get a response back from conda commands like conda info --envs. It doesn't do anything when i type that in.
If i need to uninstall conda/anaconda i will but am i just missing a simple fix?
Thanks friends!
You should install requests with conda if you plan to use conda as your python environment.
conda install requests
Related
My computer environment is ubuntu20.04,conda 22.9.0. I'm Unable to execute the [conda install] and [conda env list] commands. However, I can execute the [conda activate lf] command. When the [conda install ] and [conda env list] command is executed, this error prompt appears
Traceback (most recent call last):
File "/home/wpu/anaconda3/lib/python3.9/site-packages/conda/gateways/connection/__init__.py", line 8, in <module>
from requests import ConnectionError, HTTPError, Session
ModuleNotFoundError: No module named 'requests'
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "/home/wpu/anaconda3/bin/conda-env", line 6, in <module>
from conda_env.cli.main import main
File "/home/wpu/anaconda3/lib/python3.9/site-packages/conda_env/cli/main.py", line 13, in <module>
import conda.exports # noqa
File "/home/wpu/anaconda3/lib/python3.9/site-packages/conda/exports.py", line 24, in <module>
from . import plan # noqa: F401
File "/home/wpu/anaconda3/lib/python3.9/site-packages/conda/plan.py", line 28, in <module>
from .core.index import LAST_CHANNEL_URLS, _supplement_index_with_prefix
File "/home/wpu/anaconda3/lib/python3.9/site-packages/conda/core/index.py", line 19, in <module>
from .package_cache_data import PackageCacheData
File "/home/wpu/anaconda3/lib/python3.9/site-packages/conda/core/package_cache_data.py", line 21, in <module>
from .path_actions import CacheUrlAction, ExtractPackageAction
File "/home/wpu/anaconda3/lib/python3.9/site-packages/conda/core/path_actions.py", line 34, in <module>
from ..gateways.connection.download import download
File "/home/wpu/anaconda3/lib/python3.9/site-packages/conda/gateways/connection/__init__.py", line 21, in <module>
from pip._vendor.requests import ConnectionError, HTTPError, Session
ModuleNotFoundError: No module named 'pip'
I don't know what causes these problem. Can you help me?
I thought the [requests] module was not installed, but when I execute the [pip install requests] command, the following prompt appears:
Requirement already satisfied: requests in /usr/lib/python3/dist-packages (2.22.0)
Executing the pip statement smoothly。
I'm currently following the Scrapy tutorial and am at the step where there's a creation of a project, however this error is produced everytime I run the command scrapy startproject tutorial.
Error:
Traceback (most recent call last):
File "C:\Users\Me\Miniconda3\Scripts\scrapy-script.py", line 10, in <module>
sys.exit(execute())
File "C:\Users\Me\Miniconda3\lib\site-packages\scrapy\cmdline.py", line 149, in execute
cmd.crawler_process = CrawlerProcess(settings)
File "C:\Users\Me\Miniconda3\lib\site-packages\scrapy\crawler.py", line 252, in __init__
log_scrapy_info(self.settings)
File "C:\Users\Me\Miniconda3\lib\site-packages\scrapy\utils\log.py", line 149, in log_scrapy_info
for name, version in scrapy_components_versions()
File "C:\Users\Me\Miniconda3\lib\site-packages\scrapy\utils\versions.py", line 35, in scrapy_components_versions
("pyOpenSSL", _get_openssl_version()),
File "C:\Users\Me\Miniconda3\lib\site-packages\scrapy\utils\versions.py", line 43, in _get_openssl_version
import OpenSSL
File "C:\Users\Me\Miniconda3\lib\site-packages\OpenSSL\__init__.py", line 8, in <module>
from OpenSSL import crypto, SSL
File "C:\Users\Me\Miniconda3\lib\site-packages\OpenSSL\crypto.py", line 16, in <module>
from OpenSSL._util import (
File "C:\Users\Me\Miniconda3\lib\site-packages\OpenSSL\_util.py", line 6, in <module>
from cryptography.hazmat.bindings.openssl.binding import Binding
File "C:\Users\Me\Miniconda3\lib\site-packages\cryptography\hazmat\bindings\openssl\binding.py", line 13, in <module>
from cryptography.hazmat.bindings._openssl import ffi, lib
ImportError: DLL load failed: The specified procedure could not be found.
I suspected that the issue is in my installation of Scrapy, so I tried reinstalling Scrapy(first via pip then conda) but it still doesn't fix the problem. I then tried to install the packages that Scrapy needed(one by one) but it's still not fixing anything.
How do I go about fixing this?
Can you try to install Win64OpenSSL_Light-1_0_2h and reinstall cryptography?
pip install -I cryptography
See this existing answer.
I am testing an application and I am getting the above error "ImportError: No module named 'requests.packages.urllib3'" Below are the details.
[root#lab ~]# python /opt/test/panda_API.py
Traceback (most recent call last):
File "/opt/test/panda_API.py", line 8, in <module>
import requests
File "/usr/lib/python2.6/site-packages/requests/__init__.py", line 58, in <module>
from . import utils
File "/usr/lib/python2.6/site-packages/requests/utils.py", line 32, in <module>
from .exceptions import InvalidURL
File "/usr/lib/python2.6/site-packages/requests/exceptions.py", line 10, in <module>
from .packages.urllib3.exceptions import HTTPError as BaseHTTPError
File "/usr/lib/python2.6/site-packages/requests/packages/__init__.py", line 99, in load_module
raise ImportError("No module named '%s'" % (name,))
ImportError: No module named 'requests.packages.urllib3'
In a bid to resolve that, I try to pip install requests. Then the following error pops up.
[root#lab ~]# pip install requests
Traceback (most recent call last):
File "/usr/bin/pip", line 5, in <module>
from pkg_resources import load_entry_point
File "/usr/lib/python2.6/site-packages/pkg_resources/__init__.py", line 954, in <module>
class Environment:
File "/usr/lib/python2.6/site-packages/pkg_resources/__init__.py", line 958, in Environment
self, search_path=None, platform=get_supported_platform(),
File "/usr/lib/python2.6/site-packages/pkg_resources/__init__.py", line 188, in get_supported_platform
plat = get_build_platform()
File "/usr/lib/python2.6/site-packages/pkg_resources/__init__.py", line 388, in get_build_platform
from sysconfig import get_platform
ImportError: No module named sysconfig
I have searched for solution here on stack overflow and other platforms, the closest is the one in this page on stack overflow. (ImportError: No module named sysconfig--can't get pip working).
I have tried the steps proposed in the above link, yet the same error "ImportError: No module named sysconfig", keeps repeating.
Running "pip -V", generated the same error.
Running the recommended command to check the version of setuptools, generated the following error --------
[root#lab pkg_resources]# python2.6 -c "import setuptools; print(setuptools.__version__)"
`Traceback (most recent call last):
File "<string>", line 1, in <module>
File "/usr/lib/python2.6/site-packages/setuptools/__init__.py", line 14, in <module >
import setuptools.version
File "/usr/lib/python2.6/site-packages/setuptools/version.py", line 1, in <module>
import pkg_resources
File "/usr/lib/python2.6/site-packages/pkg_resources/__init__.py", line 954, in <mo dule>
class Environment:
File "/usr/lib/python2.6/site-packages/pkg_resources/__init__.py", line 958, in Env ironment
self, search_path=None, platform=get_supported_platform(),
File "/usr/lib/python2.6/site-packages/pkg_resources/__init__.py", line 188, in get _supported_platform
plat = get_build_platform()
File "/usr/lib/python2.6/site-packages/pkg_resources/__init__.py", line 388, in get _build_platform
from sysconfig import get_platform
ImportError: No module named sysconfig
I have checked /usr/lib/python2.6/site-packages, and I do not have pkg_resources.py. Instead, what I have is the directory pkg_resources.
It appears that I have a more complicated case. Please I need help please!
Notes:
OS: CentOS release 6.10 (Final), and Python Version: Python 2.6.6
firstly run this command,
pip install requests urllib3 pyOpenSSL --force --upgrade
then install pyOpenSSL version 16.2.0 and run this command
pip install pyOpenSSL==16.2.0
Update your distribution packages! Python 2.6 is dead.
I am trying to ensure that a library is installed in a blender instance.
I found out about ensurepip and am attempting to use it to install pip. Then I can install the external library.
However ensurepip.bootstrap() gives me the following error:
ensurepip.bootstrap()
Traceback (most recent call last):
File "<blender_console>", line 1, in <module>
File "C:\Program Files\Blender Foundation\Blender\2.74\python\lib\ensurepip\__init__.py", line 116, in bootstrap
_run_pip(args + [p[0] for p in _PROJECTS], additional_paths)
File "C:\Program Files\Blender Foundation\Blender\2.74\python\lib\ensurepip\__init__.py", line 40, in _run_pip
import pip
File "C:\Users\Ethan\AppData\Local\Temp\tmpqn93iwq6\pip-1.5.6-py2.py3-none-any.whl\pip\__init__.py", line 9, in <module>
File "C:\Users\Ethan\AppData\Local\Temp\tmpqn93iwq6\pip-1.5.6-py2.py3-none-any.whl\pip\log.py", line 8, in <module>
File "C:\Users\Ethan\AppData\Local\Temp\tmpqn93iwq6\pip-1.5.6-py2.py3-none-any.whl\pip\backwardcompat\__init__.py", line 98, in <module>
ImportError: No module named 'distutils'
I've been using PyCharm CE with pretty great success. But I just installed the basemap module (having to compile geos and basemap from source) and it seems to have broken the PyCharm interpreter. All of my modules load properly when I run Python from the terminal, and all of my modules run properly when I run Python from the terminal WITHIN PyCharm, but now when I attempt to load certain packages from the interactive interpreter, I get error messages. For example, now when I try to import pandas in the interactive interpreter, I get this:
Traceback (most recent call last):
File "/opt/local/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site- packages/IPython/core/interactiveshell.py", line 2827, in run_code
exec code_obj in self.user_global_ns, self.user_ns
File "<ipython-input-3-af55e7023913>", line 1, in <module>
import pandas as pd
File "/Library/Python/2.7/site-packages/pandas/__init__.py", line 25, in <module>
import pandas.core.config_init
File "/Library/Python/2.7/site-packages/pandas/core/config_init.py", line 4, in <module>
from pandas.core.format import detect_console_encoding
File "/Library/Python/2.7/site-packages/pandas/core/format.py", line 12, in <module>
from pandas.core.index import Index, MultiIndex, _ensure_index
File "/Library/Python/2.7/site-packages/pandas/core/index.py", line 10, in <module>
import pandas.index as _index
File "index.pyx", line 34, in init pandas.index (pandas/index.c:14957)
File "/opt/local/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site- packages/pytz/__init__.py", line 31, in <module>
from pkg_resources import resource_stream
File "/opt/local/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site- packages/pkg_resources.py", line 2717, in <module>
add_activation_listener(lambda dist: dist.activate())
File "/opt/local/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site- packages/pkg_resources.py", line 682, in subscribe
callback(dist)
File "/opt/local/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site- packages/pkg_resources.py", line 2717, in <lambda>
add_activation_listener(lambda dist: dist.activate())
File "/opt/local/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site- packages/pkg_resources.py", line 2255, in activate
list(map(declare_namespace, self._get_metadata('namespace_packages.txt')))
File "/opt/local/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site- packages/pkg_resources.py", line 1851, in declare_namespace
path = sys.modules[parent].__path__
KeyError: 'dap'
If I try to import pandas again, in the same session, the error message changes to this:
Traceback (most recent call last):
cannot import name hashtable
File "/opt/local/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site- packages/IPython/core/interactiveshell.py", line 2827, in run_code
exec code_obj in self.user_global_ns, self.user_ns
File "<ipython-input-6-af55e7023913>", line 1, in <module>
import pandas as pd
File "/Library/Python/2.7/site-packages/pandas/__init__.py", line 6, in <module>
from . import hashtable, tslib, lib
ImportError: cannot import name hashtable
What did I do to break the interpreter? I tried reinstalling PyCharm to reset and it didn't seem to work.
I case this helps anyone. I had this issue in a Django project that also was setup to use Google App Engine; therefore, PyCharm loaded the GAE version of many Python packages (they were being added to my PYTHONPATH). I disabled Google App Engine support in File -> Settings -> Languages & Frameworks -> Google App Engine. The problem went away.
Note: I did not have the Pandas import issue when running my Django app outside of PyCharm.