I have jupyter notebook installed on Mac with Python 3 Kernel. I tried to install a Kernel for Python 2 using command: python2 -m pip install ipykernel, but got the following error:
Collecting ipykernel
Using cached ipykernel-4.6.1-py2-none-any.whl
Collecting jupyter-client (from ipykernel)
Using cached jupyter_client-5.1.0-py2.py3-none-any.whl
Collecting tornado>=4.0 (from ipykernel)
Using cached tornado-4.5.1.tar.gz
Exception:
Traceback (most recent call last):
File "/usr/local/lib/python2.7/site-packages/pip/basecommand.py", line 215, in main
status = self.run(options, args)
File "/usr/local/lib/python2.7/site-packages/pip/commands/install.py", line 335, in run
wb.build(autobuilding=True)
File "/usr/local/lib/python2.7/site-packages/pip/wheel.py", line 749, in build
self.requirement_set.prepare_files(self.finder)
File "/usr/local/lib/python2.7/site-packages/pip/req/req_set.py", line 380, in prepare_files
ignore_dependencies=self.ignore_dependencies))
File "/usr/local/lib/python2.7/site-packages/pip/req/req_set.py", line 634, in _prepare_file
abstract_dist.prep_for_dist()
File "/usr/local/lib/python2.7/site-packages/pip/req/req_set.py", line 129, in prep_for_dist
self.req_to_install.run_egg_info()
File "/usr/local/lib/python2.7/site-packages/pip/req/req_install.py", line 412, in run_egg_info
self.setup_py, self.name,
File "/usr/local/lib/python2.7/site-packages/pip/req/req_install.py", line 387, in setup_py
import setuptools # noqa
File "/usr/local/lib/python2.7/site-packages/setuptools/__init__.py", line 10, in <module>
from setuptools.extern.six.moves import filter, map
File "/usr/local/lib/python2.7/site-packages/setuptools/setuptools/__init__.py", line 160, in <module>
monkey.patch_all()
File "/usr/local/lib/python2.7/site-packages/setuptools/setuptools/monkey.py", line 48, in patch_all
distutils.core.Command = setuptools.Command
AttributeError: 'module' object has no attribute 'Command'
Could anyone tell me where the problem is and how to install the kernel for python 2?
Assuming that you are running Anaconda I think that entering the following commands into your terminal may work
1) Use create a Python 2.7 conda env
conda create -n python2 python=2.7
2) Activate your new env from the terminal.
source activate python2
3) Install ipykernel into the python2 env
pip install ipykernel
4) Install the python2 kernel into ipython
ipython kernel install --name python2
If you are not running Anaconda try this tutorial; Create isolated Jupyter ipython kernels with pyenv and virtualenv
Please comment below if you are still having issues.
Related
I'm still a novice to all the advanced parts of coding. i have the 3.9.11 version of python installed. Whenever i install Pygames, I always get this result below. Any way that i could resolve this? thanks!
C:\\Users\\username\>pip install pygame==2.0.0.dev14
Collecting pygame==2.0.0.dev14
Downloading https://files.pythonhosted.org/packages/4e/f6/9031970fbd0cabb02842a68b6bd2defc55f4c1409e76712dd32c4d6e46cf/pygame-2.0.0.dev14.tar.gz (5.6MB)
100% |################################| 5.6MB 74kB/s
c:\\users\\username\\appdata\\local\\programs\\python\\python35\\lib\\site-packages_distutils_hack\__init_\_.py:18: UserWarning: Distutils was imported before Setuptools, but importing Setuptools also replaces the `distutils` module in `sys.modules`. This may lead to undesirable behaviors or errors. To avoid these issues, avoid using distutils directly, ensure that setuptools is installed in the traditional way (e.g. not an editable install), and/or make sure that setuptools is always imported before distutils.
"Distutils was imported before Setuptools, but importing Setuptools "
c:\\users\\username\\appdata\\local\\programs\\python\\python35\\lib\\site-packages_distutils_hack\__init_\_.py:30: UserWarning: Setuptools is replacing distutils.
warnings.warn("Setuptools is replacing distutils.")
Exception:
Traceback (most recent call last):
File "c:\\users\\username\\appdata\\local\\programs\\python\\python35\\lib\\site-packages\\pip\\basecommand.py", line 211, in main
status = self.run(options, args)
File "c:\\users\\username\\appdata\\local\\programs\\python\\python35\\lib\\site-packages\\pip\\commands\\install.py", line 294, in run
requirement_set.prepare_files(finder)
File "c:\\users\\username\\appdata\\local\\programs\\python\\python35\\lib\\site-packages\\pip\\req\\req_set.py", line 334, in prepare_files
functools.partial(self.\_prepare_file, finder))
File "c:\\users\\username\\appdata\\local\\programs\\python\\python35\\lib\\site-packages\\pip\\req\\req_set.py", line 321, in \_walk_req_to_install
more_reqs = handler(req_to_install)
File "c:\\users\\username\\appdata\\local\\programs\\python\\python35\\lib\\site-packages\\pip\\req\\req_set.py", line 505, in _prepare_file_
abstract_dist.prep_for_dist()
File "c:\\users\\username\\appdata\\local\\programs\\python\\python35\\lib\\site-packages\\pip\\req\\req_set.py", line 123, in prep_for_dist
self.req_to_install.run_egg_info()
File "c:\\users\\username\\appdata\\local\\programs\\python\\python35\\lib\\site-packages\\pip\\req\\req_install.py", line 376, in run_egg_info
self.setup_py, self.name,
File "c:\\users\\username\\appdata\\local\\programs\\python\\python35\\lib\\site-packages\\pip\\req\\req_install.py", line 347, in setup_py
import setuptools # noqa
File "c:\\users\\username\\appdata\\local\\programs\\python\\python35\\lib\\site-packages\\setuptools\__init_.py", line 8, in \<module\>
import _distutils_hack.override # noqa: F401_
File "c:\\users\\username\\appdata\\local\\programs\\python\\python35\\lib\\site-packages_distutils_hack\\override.py", line 1, in \<module\>
__import__('_distutils_hack').do_override()_
File "c:\\users\\username\\appdata\\local\\programs\\python\\python35\\lib\\site-packages_distutils_hack\__init_.py", line 72, in do_override
ensure_local_distutils()
File "c:\\users\\username\\appdata\\local\\programs\\python\\python35\\lib\\site-packages_distutils_hack\__init_.py", line 59, in ensure_local_distutils
assert '\_distutils' in core.__file__, core.__file__
AssertionError: c:\\users\\username\\appdata\\local\\programs\\python\\python35\\lib\\distutils\\core.py
You are using pip version 7.1.2, however version 22.0.4 is available.
You should consider upgrading via the 'python -m pip install --upgrade pip' command.
First things first, upgrade your pip putting this in your cmd: python -m pip install --upgrade pip. Why are you installing lower version of pygame? Also if you don't have a specific reason to use python 3.9, you can install python 3.10. If that doesn't work, try reinstalling python so it reinstalls the pip and then try again.
Im using python 2.7 and trying to install jsonschema package but its throwing me following error
I tried to upgrade the pip with command
pip install --upgrade pip
Also tried with command pip install jsonschema --no-use-pep517. But still no luck.
pip install jsonschema
DEPRECATION: Python 2.7 reached the end of its life on January 1st, 2020. Please upgrade your Python as Python 2.7 is no longer maintained. pip 21.0 will drop support for Python 2.7 in January 2021. More details about Python 2 support in pip can be found at https://pip.pypa.io/en/latest/development/release-process/#python-2-support pip 21.0 will remove support for this functionality.
Defaulting to user installation because normal site-packages is not writeable
Collecting jsonschema
Using cached jsonschema-4.0.0.tar.gz (290 kB)
Installing build dependencies ... done
Getting requirements to build wheel ... done
ERROR: Exception:
Traceback (most recent call last):
File "/usr/local/lib/python2.7/site-packages/pip/_internal/cli/base_command.py", line 223, in _main
status = self.run(options, args)
File "/usr/local/lib/python2.7/site-packages/pip/_internal/cli/req_command.py", line 180, in wrapper
return func(self, options, args)
File "/usr/local/lib/python2.7/site-packages/pip/_internal/commands/install.py", line 321, in run
reqs, check_supported_wheels=not options.target_dir
File "/usr/local/lib/python2.7/site-packages/pip/_internal/resolution/legacy/resolver.py", line 180, in resolve
discovered_reqs.extend(self._resolve_one(requirement_set, req))
File "/usr/local/lib/python2.7/site-packages/pip/_internal/resolution/legacy/resolver.py", line 385, in _resolve_one
dist = self._get_dist_for(req_to_install)
File "/usr/local/lib/python2.7/site-packages/pip/_internal/resolution/legacy/resolver.py", line 337, in _get_dist_for
dist = self.preparer.prepare_linked_requirement(req)
File "/usr/local/lib/python2.7/site-packages/pip/_internal/operations/prepare.py", line 480, in prepare_linked_requirement
return self._prepare_linked_requirement(req, parallel_builds)
File "/usr/local/lib/python2.7/site-packages/pip/_internal/operations/prepare.py", line 524, in _prepare_linked_requirement
req, self.req_tracker, self.finder, self.build_isolation,
File "/usr/local/lib/python2.7/site-packages/pip/_internal/operations/prepare.py", line 88, in _get_prepared_distribution
abstract_dist.prepare_distribution_metadata(finder, build_isolation)
File "/usr/local/lib/python2.7/site-packages/pip/_internal/distributions/sdist.py", line 39, in prepare_distribution_metadata
self._setup_isolation(finder)
File "/usr/local/lib/python2.7/site-packages/pip/_internal/distributions/sdist.py", line 97, in _setup_isolation
reqs = backend.get_requires_for_build_wheel()
File "/usr/local/lib/python2.7/site-packages/pip/_vendor/pep517/wrappers.py", line 178, in get_requires_for_build_wheel
'config_settings': config_settings
File "/usr/local/lib/python2.7/site-packages/pip/_vendor/pep517/wrappers.py", line 284, in _call_hook
raise BackendUnavailable(data.get('traceback', ''))
BackendUnavailable
jsonschema 3.2.0 and perhaps any version less than 4.0 support Python 2.7. Try
pip install "jsonschema<4.0"
Your Python package is 2.7 . Pip has stopped support this version. You need to upgrade your python version and then you should try this.
pip install jsonschema
I tried to update PIP (Windows 10, Python 3.7.1) in console using command:
python37 -m pip install --upgrade pip
This is an error I got everytime I try to update it:
>Exception:
Traceback (most recent call last):
File "C:\Users\5gyblo\AppData\Roaming\Python\Python37\site-packages\pip\basecommand.py", line 215, in main
status = self.run(options, args)
File "C:\Users\5gyblo\AppData\Roaming\Python\Python37\site-packages\pip\commands\install.py", line 342, in run
prefix=options.prefix_path,
File "C:\Users\5gyblo\AppData\Roaming\Python\Python37\site-packages\pip\req\req_set.py", line 784, in install
**kwargs
File "C:\Users\5gyblo\AppData\Roaming\Python\Python37\site-packages\pip\req\req_install.py", line 851, in install
self.move_wheel_files(self.source_dir, root=root, prefix=prefix)
File "C:\Users\5gyblo\AppData\Roaming\Python\Python37\site-packages\pip\req\req_install.py", line 1064, in move_wheel_files
isolated=self.isolated,
File "C:\Users\5gyblo\AppData\Roaming\Python\Python37\site-packages\pip\wheel.py", line 462, in move_wheel_files
generated.extend(maker.make(spec))
File "C:\Users\5gyblo\AppData\Roaming\Python\Python37\site-packages\pip\_vendor\distlib\scripts.py", line 372, in make
self._make_script(entry, filenames, options=options)
File "C:\Users\5gyblo\AppData\Roaming\Python\Python37\site-packages\pip\_vendor\distlib\scripts.py", line 276, in _make_script
self._write_script(scriptnames, shebang, script, filenames, ext)
File "C:\Users\5gyblo\AppData\Roaming\Python\Python37\site-packages\pip\_vendor\distlib\scripts.py", line 212, in _write_script
launcher = self._get_launcher('t')
File "C:\Users\5gyblo\AppData\Roaming\Python\Python37\site-packages\pip\_vendor\distlib\scripts.py", line 351, in _get_launcher
result = finder(distlib_package).find(name).bytes
AttributeError: 'NoneType' object has no attribute 'bytes'
Surprising fact - I had succesfully updated PIP on Python 2.7 isntance without any problems.
I faced this error while trying to upgrade from pip version 18.1 to 19.0.3.
After a lot of search I hit the solution at https://packaging.python.org/tutorials/installing-packages/
(If that still doesn’t allow you to run pip:
Securely Download get-pip.py [1]
Run python get-pip.py. [2] This will install or upgrade pip. Additionally, it will install setuptools and wheel if they’re not installed already.)
The link there takes you to:
Use https://bootstrap.pypa.io/get-pip.py
Download and save the file, run it from command prompt. It worked like a charm for me.
You can try:
python -m pip install -U --force-reinstall pip
I'm trying to install jupyter to use the IPython Notebook under Windows. However, if I run pip install jupyter I'm getting
Using cached pyzmq-15.4.0.zip
Requirement already satisfied (use --upgrade to upgrade): wcwidth in c:\users\stefan\appdata\local\programs\python\python36\lib\site-packages (from prompt-toolkit<2.0.0,>=1.0.0->jupyter-console->jupyter)
Installing collected packages: nbformat, nbconvert, pyzmq, jupyter-client, tornado, ipykernel, notebook, widgetsnbextension, ipywidgets, qtconsole, jupyter-console, jupyter
Exception:
Traceback (most recent call last):
File "C:\Users\Stefan\AppData\Local\Programs\Python\Python36\lib\site-packages\pip\basecommand.py", line 215, in main
status = self.run(options, args)
File "C:\Users\Stefan\AppData\Local\Programs\Python\Python36\lib\site-packages\pip\commands\install.py", line 317, in run
prefix=options.prefix_path,
File "C:\Users\Stefan\AppData\Local\Programs\Python\Python36\lib\site-packages\pip\req\req_set.py", line 742, in install
**kwargs
File "C:\Users\Stefan\AppData\Local\Programs\Python\Python36\lib\site-packages\pip\req\req_install.py", line 831, in install
self.move_wheel_files(self.source_dir, root=root, prefix=prefix)
File "C:\Users\Stefan\AppData\Local\Programs\Python\Python36\lib\site-packages\pip\req\req_install.py", line 1032, in move_wheel_files
isolated=self.isolated,
File "C:\Users\Stefan\AppData\Local\Programs\Python\Python36\lib\site-packages\pip\wheel.py", line 493, in move_wheel_files
maker.make_multiple(['%s = %s' % kv for kv in console.items()])
File "C:\Users\Stefan\AppData\Local\Programs\Python\Python36\lib\site-packages\pip\_vendor\distlib\scripts.py", line 383, in make_multiple
filenames.extend(self.make(specification, options))
File "C:\Users\Stefan\AppData\Local\Programs\Python\Python36\lib\site-packages\pip\_vendor\distlib\scripts.py", line 372, in make
self._make_script(entry, filenames, options=options)
File "C:\Users\Stefan\AppData\Local\Programs\Python\Python36\lib\site-packages\pip\_vendor\distlib\scripts.py", line 276, in _make_script
self._write_script(scriptnames, shebang, script, filenames, ext)
File "C:\Users\Stefan\AppData\Local\Programs\Python\Python36\lib\site-packages\pip\_vendor\distlib\scripts.py", line 212, in _write_script
launcher = self._get_launcher('t')
File "C:\Users\Stefan\AppData\Local\Programs\Python\Python36\lib\site-packages\pip\_vendor\distlib\scripts.py", line 351, in _get_launcher
result = finder(distlib_package).find(name).bytes
File "C:\Users\Stefan\AppData\Local\Programs\Python\Python36\lib\site-packages\pip\_vendor\distlib\resources.py", line 324, in finder
raise DistlibException('Unable to locate finder for %r' % package)
pip._vendor.distlib.DistlibException: Unable to locate finder for 'pip._vendor.distlib'
Any idea what the problem here is?
uninstall current pip by typing:
python -m pip uninstall pip setuptools
download get-pip.py from https://bootstrap.pypa.io/get-pip.py and run it:
python get-pip.py
Try uninstalling pip and installing get-pip.py. It appears to be a bug in the 3.6 version for Windows. https://github.com/pypa/pip/issues/3964
Recently bought a new Mac and was setting it up for both Python and iOS development. Python was working fine--especially pip'ing git repos with lots of requirements.txt dependencies UNTIL I installed Xcode, macports and Apple's command line tools.
Now pip works fine for individual install (e.g., pip install twilio), but whenever I run pip against a requirements.txt file it fails (with or without sudo):
pip install ./requirements.txt
Exception:
Traceback (most recent call last):
File "/Library/Python/2.7/site-packages/pip-1.2.1-py2.7.egg/pip/basecommand.py", line 107, in main
status = self.run(options, args)
File "/Library/Python/2.7/site-packages/pip-1.2.1-py2.7.egg/pip/commands/install.py", line 225, in run
InstallRequirement.from_line(name, None))
File "/Library/Python/2.7/site-packages/pip-1.2.1-py2.7.egg/pip/req.py", line 118, in from_line
return cls(req, comes_from, url=url)
File "/Library/Python/2.7/site-packages/pip-1.2.1-py2.7.egg/pip/req.py", line 43, in __init__
req = pkg_resources.Requirement.parse(req)
File "/System/Library/Frameworks/Python.framework/Versions/2.7/Extras/lib/python/pkg_resources.py", line 2510, in parse
reqs = list(parse_requirements(s))
File "/System/Library/Frameworks/Python.framework/Versions/2.7/Extras/lib/python/pkg_resources.py", line 2436, in parse_requirements
line, p, specs = scan_list(VERSION,LINE_END,line,p,(1,2),"version spec")
File "/System/Library/Frameworks/Python.framework/Versions/2.7/Extras/lib/python/pkg_resources.py", line 2404, in scan_list
raise ValueError("Expected "+item_name+" in",line,"at",line[p:])
ValueError: ('Expected version spec in', './requirements.txt', 'at', '/requirements.txt')
My $PATH value is
/Library/Frameworks/Python.framework/Versions/2.7/bin:/usr/bin:/bin:/usr/sbin:/sbin:/usr/local/bin:/usr/local/git/bin
This looks different than the "Python pip broken after OS X 10.8 upgrade" thread. I am wonder if macports created a conflict between looking in /System/Libary and ~/Library.
Any ideas?
If you want to install packages through a requirements file, you need the --requirement/-r option:
$ pip install -r requirements.txt
$ pip3 install -r requirements.txt