I am trying to turn on Pylint.
I type in 'Ctrl + Shift + P', and I click Python: Select Linter, and then I try to click 'bandit'.
When I do this, the pop up window in the bottom right corner says 'Linter bandit is not installed'.
When I click install, I get:
Collecting bandit
Using cached https://files.pythonhosted.org/packages/5a/50/ff2f2c8f1f0ca1569f678eeb608c0f973b835985410985594fbee96be820/bandit-1.6.2-py2.py3-none-any.whl
Exception:
Traceback (most recent call last):
File "C:\Users\Scott\AppData\Local\Programs\Python\Python35-32\lib\site-packages\pip\_vendor\pkg_resources\__init__.py", line 2795, in _dep_map
return self.__dep_map
File "C:\Users\Scott\AppData\Local\Programs\Python\Python35-32\lib\site-packages\pip\_vendor\pkg_resources\__init__.py", line 2652, in __getattr__
raise AttributeError(attr)
AttributeError: _DistInfoDistribution__dep_map
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "C:\Users\Scott\AppData\Local\Programs\Python\Python35-32\lib\site-packages\pip\basecommand.py", line 211, in main
status = self.run(options, args)
File "C:\Users\Scott\AppData\Local\Programs\Python\Python35-32\lib\site-packages\pip\commands\install.py", line 294, in run
requirement_set.prepare_files(finder)
File "C:\Users\Scott\AppData\Local\Programs\Python\Python35-32\lib\site-packages\pip\req\req_set.py", line 334, in prepare_files
functools.partial(self._prepare_file, finder))
File "C:\Users\Scott\AppData\Local\Programs\Python\Python35-32\lib\site-packages\pip\req\req_set.py", line 321, in _walk_req_to_install
more_reqs = handler(req_to_install)
File "C:\Users\Scott\AppData\Local\Programs\Python\Python35-32\lib\site-packages\pip\req\req_set.py", line 561, in _prepare_file
set(req_to_install.extras) - set(dist.extras)
File "C:\Users\Scott\AppData\Local\Programs\Python\Python35-32\lib\site-packages\pip\_vendor\pkg_resources\__init__.py", line 2774, in extras
return [dep for dep in self._dep_map if dep]
File "C:\Users\Scott\AppData\Local\Programs\Python\Python35-32\lib\site-packages\pip\_vendor\pkg_resources\__init__.py", line 2797, in _dep_map
self.__dep_map = self._compute_dependencies()
File "C:\Users\Scott\AppData\Local\Programs\Python\Python35-32\lib\site-packages\pip\_vendor\pkg_resources\__init__.py", line 2830, in _compute_dependencies
common = frozenset(reqs_for_extra(None))
File "C:\Users\Scott\AppData\Local\Programs\Python\Python35-32\lib\site-packages\pip\_vendor\pkg_resources\__init__.py", line 2827, in reqs_for_extra
if req.marker_fn(override={'extra':extra}):
File "C:\Users\Scott\AppData\Local\Programs\Python\Python35-32\lib\site-packages\pip\_vendor\_markerlib\markers.py", line 113, in marker_fn
return eval(compiled_marker, environment)
File "<environment marker>", line 1, in <module>
NameError: name 'platform_system' is not defined
You are using pip version 7.1.2, however version 19.3.1 is available.
You should consider upgrading via the 'python -m pip install --upgrade pip' command.
I have already upgraded my pip version to the most recent. Basic Googling tells me that this is using a virtual environment, and the venv is using an earlier version of pip, but I have no idea how to fix this.
Please help.
Related
i run the command bellow on widows command line
pip install requests
the error that apeared is :
Exception:
Traceback (most recent call last):
File "C:\Python27\lib\site-packages\pip\basecommand.py", line 122, in main
status = self.run(options, args)
File "C:\Python27\lib\site-packages\pip\commands\install.py", line 278, in run
requirement_set.prepare_files(finder, force_root_egg_info=self.bundle, bundle=self.bundle)
File "C:\Python27\lib\site-packages\pip\req.py", line 1265, in prepare_files
req_to_install.extras):
File "C:\Python27\lib\site-packages\pip\_vendor\pkg_resources.py", line 2291, in requires
dm = self._dep_map
File "C:\Python27\lib\site-packages\pip\_vendor\pkg_resources.py", line 2484, in _dep_map
self.__dep_map = self._compute_dependencies()
File "C:\Python27\lib\site-packages\pip\_vendor\pkg_resources.py", line 2508, in _compute_dependencies
parsed = next(parse_requirements(distvers))
File "C:\Python27\lib\site-packages\pip\_vendor\pkg_resources.py", line 45, in <lambda>
next = lambda o: o.next()
File "C:\Python27\lib\site-packages\pip\_vendor\pkg_resources.py", line 2605, in parse_requirements
line, p, specs = scan_list(VERSION,LINE_END,line,p,(1,2),"version spec")
File "C:\Python27\lib\site-packages\pip\_vendor\pkg_resources.py", line 2573, in scan_list
raise ValueError("Expected "+item_name+" in",line,"at",line[p:])
ValueError: ('Expected version spec in', 'charset-normalizer ~=2.0.0', 'at', ' ~=2.0.0')
Storing debug log for failure in C:\Users\mchaa\pip\pip.log
ps: i tried to install it from github and the same error every time i don't know how to fix it
solution :
i use the command bellow to uninstall
uninstall current pip:
python -m pip uninstall pip setuptools
download get-pip.py from https://bootstrap.pypa.io/pip/2.7/get-pip.py instead.
after downloding it put it in the same folder that excute the python's command
execute get-pip script:
python get-pip.py
I think i have messed up some python files when installing some packages in a requirement.txt file
now i get these errors when trying to install or uninstall anything:
for example when trying to uninstall matplotlib without sudo using pip3 uninstall matplotlib (even tho i never had to use sudo to uninstall anything before) :
Found existing installation: matplotlib 3.3.1
Uninstalling matplotlib-3.3.1:
Would remove:
/usr/local/lib/python3.8/dist-packages/matplotlib-3.3.1-py3.8-linux-x86_64.egg
Proceed (y/n)? y
ERROR: Exception:
Traceback (most recent call last):
File "/usr/lib/python3.8/shutil.py", line 788, in move
os.rename(src, real_dst)
PermissionError: [Errno 13] Permission denied: '/usr/local/lib/python3.8/dist-packages/matplotlib-3.3.1-py3.8-linux-x86_64.egg' -> '/tmp/pip-uninstall-nw393b36'
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "/home/john/.local/lib/python3.8/site-packages/pip/_internal/cli/base_command.py", line 228, in _main
status = self.run(options, args)
File "/home/john/.local/lib/python3.8/site-packages/pip/_internal/commands/uninstall.py", line 89, in run
uninstall_pathset = req.uninstall(
File "/home/john/.local/lib/python3.8/site-packages/pip/_internal/req/req_install.py", line 686, in uninstall
uninstalled_pathset.remove(auto_confirm, verbose)
File "/home/john/.local/lib/python3.8/site-packages/pip/_internal/req/req_uninstall.py", line 394, in remove
moved.stash(path)
File "/home/john/.local/lib/python3.8/site-packages/pip/_internal/req/req_uninstall.py", line 283, in stash
renames(path, new_path)
File "/home/john/.local/lib/python3.8/site-packages/pip/_internal/utils/misc.py", line 352, in renames
shutil.move(old, new)
File "/usr/lib/python3.8/shutil.py", line 800, in move
rmtree(src)
File "/usr/lib/python3.8/shutil.py", line 715, in rmtree
_rmtree_safe_fd(fd, path, onerror)
File "/usr/lib/python3.8/shutil.py", line 672, in _rmtree_safe_fd
onerror(os.unlink, fullname, sys.exc_info())
File "/usr/lib/python3.8/shutil.py", line 670, in _rmtree_safe_fd
os.unlink(entry.name, dir_fd=topfd)
PermissionError: [Errno 13] Permission denied: 'pylab.py'
When trying with sudo :
Exception:
Traceback (most recent call last):
File "/usr/local/lib/python3.8/dist-packages/pip/basecommand.py", line 209, in main
status = self.run(options, args)
File "/usr/local/lib/python3.8/dist-packages/pip/commands/uninstall.py", line 46, in run
with self._build_session(options) as session:
File "/usr/local/lib/python3.8/dist-packages/pip/basecommand.py", line 66, in _build_session
session = PipSession(
File "/usr/local/lib/python3.8/dist-packages/pip/download.py", line 321, in __init__
self.headers["User-Agent"] = user_agent()
File "/usr/local/lib/python3.8/dist-packages/pip/download.py", line 93, in user_agent
zip(["name", "version", "id"], platform.linux_distribution()),
AttributeError: module 'platform' has no attribute 'linux_distribution'
Traceback (most recent call last):
File "/usr/local/bin/pip3", line 33, in <module>
sys.exit(load_entry_point('pip==20.3.dev0', 'console_scripts', 'pip3')())
File "/usr/local/lib/python3.8/dist-packages/pip/__init__.py", line 217, in main
return command.main(cmd_args)
File "/usr/local/lib/python3.8/dist-packages/pip/basecommand.py", line 242, in main
with self._build_session(
File "/usr/local/lib/python3.8/dist-packages/pip/basecommand.py", line 66, in _build_session
session = PipSession(
File "/usr/local/lib/python3.8/dist-packages/pip/download.py", line 321, in __init__
self.headers["User-Agent"] = user_agent()
File "/usr/local/lib/python3.8/dist-packages/pip/download.py", line 93, in user_agent
zip(["name", "version", "id"], platform.linux_distribution()),
AttributeError: module 'platform' has no attribute 'linux_distribution'
How can i fix this? i am using ubuntu 20.04 and i heard uninstalling python3.8 is a big no no since many system files use it, so what should i do?
tried many suggestion on similar questions like this and it didn't work:
How to fix "module 'platform' has no attribute 'linux_distribution'" when installing new packages with Python3.8?
Python 3.8 removed some stuff. I solved my problems with pip (specifically pip install) by installing pip with curl
What worked for me was:
cd ~/Downloads
Downloading get-pip.py
curl https://bootstrap.pypa.io/get-pip.py -o get-pip.py
Then running it with python 3.8:
python3.8 get-pip.py
Solved it for me.
While running $ pip install <package>, I am getting below error, in this case I am installing PyJWT and also checked for other packages to crosscheck. This happened after upgrading pip to 19.0.2 from 19.0.1.
Check below errors while running pip install PyJWT, requirement are already satisfied, but still I am getting error, please suggest how to fix it.
$ easy_install pip
for reinstalling the pip.
$ pip install PyJWT
Tejeshs-MacBook-Air:selenium_testing tejeshagrawal$ pip install PyJWT
Requirement already satisfied: PyJWT in
/usr/local/lib/python3.7/site-packages (1.7.1) Error checking for
conflicts. Traceback (most recent call last): File
"/Users/tejeshagrawal/Library/Python/3.7/lib/python/site-packages/pip/_vendor/pkg_resources/__init__.py",
line 2897, in _dep_map
return self.__dep_map File "/Users/tejeshagrawal/Library/Python/3.7/lib/python/site-packages/pip/_vendor/pkg_resources/__init__.py",
line 2691, in __getattr__
raise AttributeError(attr) AttributeError: _DistInfoDistribution__dep_map
**During handling of the above exception, another exception occurred:**
Traceback (most recent call last): File
"/Users/tejeshagrawal/Library/Python/3.7/lib/python/site-packages/pip/_vendor/pkg_resources/__init__.py",
line 2888, in _parsed_pkg_info
return self._pkg_info File "/Users/tejeshagrawal/Library/Python/3.7/lib/python/site-packages/pip/_vendor/pkg_resources/__init__.py",
line 2691, in __getattr__
raise AttributeError(attr) AttributeError: _pkg_info
**During handling of the above exception, another exception occurred:**
Traceback (most recent call last): File
"/Users/tejeshagrawal/Library/Python/3.7/lib/python/site-packages/pip/_internal/commands/install.py",
line 503, in _warn_about_conflicts
package_set, _dep_info = check_install_conflicts(to_install) File
"/Users/tejeshagrawal/Library/Python/3.7/lib/python/site-packages/pip/_internal/operations/check.py",
line 108, in check_install_conflicts
package_set, _ = create_package_set_from_installed() File "/Users/tejeshagrawal/Library/Python/3.7/lib/python/site-packages/pip/_internal/operations/check.py",
line 47, in create_package_set_from_installed
package_set[name] = PackageDetails(dist.version, dist.requires()) File
"/Users/tejeshagrawal/Library/Python/3.7/lib/python/site-packages/pip/_vendor/pkg_resources/__init__.py",
line 2635, in requires
dm = self._dep_map File "/Users/tejeshagrawal/Library/Python/3.7/lib/python/site-packages/pip/_vendor/pkg_resources/__init__.py",
line 2899, in _dep_map
self.__dep_map = self._compute_dependencies() File "/Users/tejeshagrawal/Library/Python/3.7/lib/python/site-packages/pip/_vendor/pkg_resources/__init__.py",
line 2908, in _compute_dependencies
for req in self._parsed_pkg_info.get_all('Requires-Dist') or []: File
"/Users/tejeshagrawal/Library/Python/3.7/lib/python/site-packages/pip/_vendor/pkg_resources/__init__.py",
line 2890, in _parsed_pkg_info
metadata = self.get_metadata(self.PKG_INFO) File "/Users/tejeshagrawal/Library/Python/3.7/lib/python/site-packages/pip/_vendor/pkg_resources/__init__.py",
line 1410, in get_metadata
value = self._get(self._fn(self.egg_info, name)) File "/Users/tejeshagrawal/Library/Python/3.7/lib/python/site-packages/pip/_vendor/pkg_resources/__init__.py",
line 1522, in _get
with open(path, 'rb') as stream: FileNotFoundError: [Errno 2] No such file or directory:
'/usr/local/lib/python3.7/site-packages/~ip-18.1.dist-info/METADATA'
Tejeshs-MacBook-Air:selenium_testing tejeshagrawal$ pip freeze >
require.txt Could not parse requirement: -ip Exception: Traceback
(most recent call last): File
"/Users/tejeshagrawal/Library/Python/3.7/lib/python/site-packages/pip/_vendor/pkg_resources/__init__.py",
line 2584, in version
return self._version File "/Users/tejeshagrawal/Library/Python/3.7/lib/python/site-packages/pip/_vendor/pkg_resources/__init__.py",
line 2691, in __getattr__
raise AttributeError(attr) AttributeError: _version
**During handling of the above exception, another exception occurred:**
Traceback (most recent call last): File
"/Users/tejeshagrawal/Library/Python/3.7/lib/python/site-packages/pip/_internal/cli/base_command.py",
line 179, in main
status = self.run(options, args) File "/Users/tejeshagrawal/Library/Python/3.7/lib/python/site-packages/pip/_internal/commands/freeze.py",
line 93, in run
for line in freeze(**freeze_kwargs): File "/Users/tejeshagrawal/Library/Python/3.7/lib/python/site-packages/pip/_internal/operations/freeze.py",
line 62, in freeze
req = FrozenRequirement.from_dist(dist) File "/Users/tejeshagrawal/Library/Python/3.7/lib/python/site-packages/pip/_internal/operations/freeze.py",
line 239, in from_dist
req = dist.as_requirement() File "/Users/tejeshagrawal/Library/Python/3.7/lib/python/site-packages/pip/_vendor/pkg_resources/__init__.py",
line 2716, in as_requirement
if isinstance(self.parsed_version, packaging.version.Version): File
"/Users/tejeshagrawal/Library/Python/3.7/lib/python/site-packages/pip/_vendor/pkg_resources/__init__.py",
line 2551, in parsed_version
self._parsed_version = parse_version(self.version) File "/Users/tejeshagrawal/Library/Python/3.7/lib/python/site-packages/pip/_vendor/pkg_resources/__init__.py",
line 2589, in version
raise ValueError(tmpl % self.PKG_INFO, self) ValueError: ("Missing 'Version:' header and/or METADATA file", Unknown [unknown version]
(/usr/local/lib/python3.7/site-packages))
Seems like your problem is similar or the same as this bug which was ironically fixed in 19.0.2. The problem is somewhere along the line you tried to install a module and it failed. pip didn't properly clean up after itself and left a package in a broken state.
The solution seems to be to find any directories starting with - in your site-packages directory (/Users/tejeshagrawal/Library/Python/3.7/lib/python/site-packages in your case) and rename them to what they should be. eg. if you find -yJWT-1.0.dist-info then you should rename it to PyJWT-1.0.dist-info. If you're not sure what it's real name should be then look for the Name value in -yJWT-1.0.dist-info/METADATA. NB. I just used PyJWT as an example, it might not be the package(s) that is/are broken. After that pip should be able to get up and running again.
Complementary finding:
Using #Dunes answer, couldn't fix the file name so I ended-up unninstalling every package from PIP
PowerShell pip uninstall -y (pip freeze)
When the loop broke on the Plackage "Plotly" I found the culprit.
You could try to install the package pip-conflict-checker:
pip install pip-conflict-checker
and then run the command:
pipconflictchecker
this will show you the packages that cause troubles
You can create a virtual environment as well by following this link:- https://docs.conda.io/projects/conda/en/latest/user-guide/tasks/manage-environments.html#creating-an-environment-with-commands
Step 1: conda create -n myenv python=3.7.4
Step 2: conda activate myenv
Step 3: pip install package_name
This helps to manage an individual conda environment to manage packages.
I'm trying to install a package from my company's internal artifactory storage. I'm getting 2 exceptions in Gitbash that I can't understand. When I run Pip Freeze I don't see the install package, so I don't believe it is already installed.
After reading the exceptions, I don't understand what's going on, is anyone familiar with this?
pip install --no-dependencies --user -i https://artifactory.cloud.company.com/artifactory/api/pypi/pypi-python-org/simple git+https://github.kdc.company.com/MandR/package.git
Looking in indexes: https://artifactory.cloud.company.com/artifactory/api/pypi/pypi-python-org/simple
Collecting git+https://github.kdc.company.com/MandR/package.git
Cloning https://github.kdc.company.com/MandR/package.git to c:\users\user_name\appdata\local\temp\pip-req-build-ptb41on4
Exception:
Traceback (most recent call last):
File "c:\users\user_name\appdata\local\continuum\anaconda3\lib\site-packages\pip\_internal\req\req_install.py", line 339, in check_if_exists
self.satisfied_by = pkg_resources.get_distribution(str(no_marker))
File "c:\users\user_name\appdata\local\continuum\anaconda3\lib\site-packages\pip\_vendor\pkg_resources\__init__.py", line 476, in get_distribution
dist = get_provider(dist)
File "c:\users\user_name\appdata\local\continuum\anaconda3\lib\site-packages\pip\_vendor\pkg_resources\__init__.py", line 352, in get_provider
return working_set.find(moduleOrReq) or require(str(moduleOrReq))[0]
File "c:\users\user_name\appdata\local\continuum\anaconda3\lib\site-packages\pip\_vendor\pkg_resources\__init__.py", line 895, in require
needed = self.resolve(parse_requirements(requirements))
File "c:\users\user_name\appdata\local\continuum\anaconda3\lib\site-packages\pip\_vendor\pkg_resources\__init__.py", line 786, in resolve
raise VersionConflict(dist, req).with_context(dependent_req)
pip._vendor.pkg_resources.ContextualVersionConflict: (tables 3.4.3 (c:\users\user_name\appdata\local\continuum\anaconda3\lib\site-packages), Requirement.parse('tables==3.2.0'), {'package'})
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "c:\users\user_name\appdata\local\continuum\anaconda3\lib\site-packages\pip\_internal\cli\base_command.py", line 143, in main
status = self.run(options, args)
File "c:\users\user_name\appdata\local\continuum\anaconda3\lib\site-packages\pip\_internal\commands\install.py", line 318, in run
resolver.resolve(requirement_set)
File "c:\users\user_name\appdata\local\continuum\anaconda3\lib\site-packages\pip\_internal\resolve.py", line 102, in resolve
self._resolve_one(requirement_set, req)
File "c:\users\user_name\appdata\local\continuum\anaconda3\lib\site-packages\pip\_internal\resolve.py", line 256, in _resolve_one
abstract_dist = self._get_abstract_dist_for(req_to_install)
File "c:\users\user_name\appdata\local\continuum\anaconda3\lib\site-packages\pip\_internal\resolve.py", line 221, in _get_abstract_dist_for
req.check_if_exists(self.use_user_site)
File "c:\users\user_name\appdata\local\continuum\anaconda3\lib\site-packages\pip\_internal\req\req_install.py", line 350, in check_if_exists
self.req.name
File "c:\users\user_name\appdata\local\continuum\anaconda3\lib\site-packages\pip\_vendor\pkg_resources\__init__.py", line 476, in get_distribution
dist = get_provider(dist)
File "c:\users\user_name\appdata\local\continuum\anaconda3\lib\site-packages\pip\_vendor\pkg_resources\__init__.py", line 352, in get_provider
return working_set.find(moduleOrReq) or require(str(moduleOrReq))[0]
File "c:\users\user_name\appdata\local\continuum\anaconda3\lib\site-packages\pip\_vendor\pkg_resources\__init__.py", line 895, in require
needed = self.resolve(parse_requirements(requirements))
File "c:\users\user_name\appdata\local\continuum\anaconda3\lib\site-packages\pip\_vendor\pkg_resources\__init__.py", line 786, in resolve
raise VersionConflict(dist, req).with_context(dependent_req)
pip._vendor.pkg_resources.ContextualVersionConflict: (tables 3.4.3 (c:\users\user_name\appdata\local\continuum\anaconda3\lib\site-packages), Requirement.parse('tables==3.2.0'), {'package'})
It looks like you have the wrong version of the tables package installed. Trying installing the required version with pip install tables==3.2.0.
After know that jwt package is incompatible with python2, I am trying to install it with pip3:
sudo pip3 install jwt
I am getting the following output:
Exception:
Traceback (most recent call last):
File "/usr/lib/python3/dist-packages/pkg_resources.py", line 2482, in
_dep_map
return self.dep_map
File "/usr/lib/python3/dist-packages/pkg_resources.py", line 2344, in
__getattr
raise AttributeError(attr) AttributeError: _DistInfoDistribution__dep_map
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "/usr/lib/python3/dist-packages/pip/basecommand.py", line 122, in main
status = self.run(options, args)
File "/usr/lib/python3/dist-packages/pip/commands/install.py", line 278, in run
requirement_set.prepare_files(finder, force_root_egg_info=self.bundle, bundle=self.bundle)
File
"/usr/lib/python3/dist-packages/pip/req.py", line 1266, in
prepare_files
req_to_install.extras):
File "/usr/lib/python3/dist-packages/pkg_resources.py", line 2291, in
requires
dm = self._dep_map File "/usr/lib/python3/dist-packages/pkg_resources.py", line 2484, in
_dep_map
self.__dep_map = self._compute_dependencies()
File "/usr/lib/python3/dist-packages/pkg_resources.py", line 2508, in
_compute_dependencies
parsed = next(parse_requirements(distvers))
File "/usr/lib/python3/dist-packages/pkg_resources.py", line 2605, in
parse_requirements
line, p, specs = scan_list(VERSION,LINE_END,line,p,(1,2),"version spec")
File "/usr/lib/python3/dist-packages/pkg_resources.py", line
2583, in scan_list
"Expected ',' or end-of-list in",line,"at",line[p:] ValueError: ("Expected ',' or end-of-list in", 'cryptography <2.,>=1.7.2', 'at',
',>=1.7.2')
Any help?
Solved problem. I had to upgrade pip3:
pip3 install --upgrade
After this, I am able to install jwt with the following:
pip3 install jwt