简体   繁体   中英

Why am I Unable to install flask (PIP error)?

I am Unable to install Flask or nearly any other modules. My OS: Ubuntu 14.04 LTS (32bit). Ubuntu Comes with pre installed Python2 and Python3. As I had work with flask, I tried to install it with the following command:

pip3 install flask

and this was the output in the terminal:

root@Ashu-linx:/var/www# pip3 install flask
Downloading/unpacking flask
Downloading Flask-2.0.1-py3-none-any.whl (94kB): 94kB downloaded
Downloading/unpacking itsdangerous>=2.0 (from flask)
Downloading itsdangerous-2.0.1-py3-none-any.whl
Downloading/unpacking Jinja2>=3.0 (from flask)
Downloading Jinja2-3.0.1-py3-none-any.whl (133kB): 133kB downloaded
Downloading/unpacking Werkzeug>=2.0 (from flask)
Downloading Werkzeug-2.0.1-py3-none-any.whl (288kB): 288kB downloaded
Downloading/unpacking click>=7.1.2 (from flask)
Downloading click-8.0.1-py3-none-any.whl (97kB): 97kB downloaded
Cleaning up...
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 2517, in 
_compute_dependencies
common = frozenset(reqs_for_extra(None))
File "/usr/lib/python3/dist-packages/pkg_resources.py", line 2514, in reqs_for_extra
if req.marker_fn(override={'extra':extra}):
File "/usr/share/python-wheels/setuptools-3.3-py2.py3-none- 
any.whl/_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

Storing debug log for failure in /root/.pip/pip.log

Then I checked My PIP version with the help of:

pip3 --version

And The Output Was:

pip 1.5.4 from /usr/lib/python3/dist-packages (python 3.4)

Then I thought of updating it first:

pip install --upgrade pip

Then It gave me the following error:

Cannot fetch index base URL https://pypi.python.org/simple/
Could not find any downloads that satisfy the requirement pip in 
/usr/lib/python2.7/dist-packages
Downloading/unpacking pip
Cleaning up...
No distributions at all found for pip in /usr/lib/python2.7/dist-packages
Storing debug log for failure in /root/.pip/pip.log

Then I searched for this error online and found a stackoverflow page And found the following command:

pip install --index-url=https://pypi.python.org/simple/flask

Then I ran the same command but a warning came:

You must give at least one requirement to install (see "pip help install")

Can someone tell me what should I do now? I have read the Flask Installation Guide but It didn't help me.

File "<environment marker>", line 1, in <module>
NameError: name 'platform_system' is not defined

This means that version of pip (in Python 3.4) that you used is too old for the newer versions of the module. The solution is to upgrade pip, but you ended up upgrading the Python 2 pip instead.

The best way to make sure you are targeting the right pip is to run it like this:

python3 -m pip install --upgrade pip

Or,

pip3 install --upgrade pip

In Windows,

py -3.4 -m pip install --upgrade pip

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM