You are not logged in.

#1 2020-10-24 02:35:49

si67
Member
Registered: 2020-09-06
Posts: 26

[Solved] Cant install pip packages?

I'm new to python and i have to install flask for a tutorial

python -m pip install flask

gives me these errors

Traceback (most recent call last):
  File "/usr/lib/python3.8/runpy.py", line 194, in _run_module_as_main
    return _run_code(code, main_globals, None,
  File "/usr/lib/python3.8/runpy.py", line 87, in _run_code
    exec(code, run_globals)
  File "/usr/lib/python3.8/site-packages/pip/__main__.py", line 26, in <module>
    sys.exit(_main())
  File "/usr/lib/python3.8/site-packages/pip/_internal/cli/main.py", line 73, in main
    command = create_command(cmd_name, isolated=("--isolated" in cmd_args))
  File "/usr/lib/python3.8/site-packages/pip/_internal/commands/__init__.py", line 104, in create_command
    module = importlib.import_module(module_path)
  File "/usr/lib/python3.8/importlib/__init__.py", line 127, in import_module
    return _bootstrap._gcd_import(name[level:], package, level)
  File "<frozen importlib._bootstrap>", line 1014, in _gcd_import
  File "<frozen importlib._bootstrap>", line 991, in _find_and_load
  File "<frozen importlib._bootstrap>", line 975, in _find_and_load_unlocked
  File "<frozen importlib._bootstrap>", line 671, in _load_unlocked
  File "<frozen importlib._bootstrap_external>", line 783, in exec_module
  File "<frozen importlib._bootstrap>", line 219, in _call_with_frames_removed
  File "/usr/lib/python3.8/site-packages/pip/_internal/commands/install.py", line 24, in <module>
    from pip._internal.cli.req_command import RequirementCommand, with_cleanup
  File "/usr/lib/python3.8/site-packages/pip/_internal/cli/req_command.py", line 20, in <module>
    from pip._internal.operations.prepare import RequirementPreparer
  File "/usr/lib/python3.8/site-packages/pip/_internal/operations/prepare.py", line 15, in <module>
    from pip._internal.distributions import (
  File "/usr/lib/python3.8/site-packages/pip/_internal/distributions/__init__.py", line 2, in <module>
    from pip._internal.distributions.wheel import WheelDistribution
  File "/usr/lib/python3.8/site-packages/pip/_internal/distributions/wheel.py", line 5, in <module>
    from pip._internal.utils.wheel import pkg_resources_distribution_for_wheel
  File "/usr/lib/python3.8/site-packages/pip/_internal/utils/wheel.py", line 12, in <module>
    from pip._vendor.six import PY2, ensure_str
ImportError: cannot import name 'ensure_str' from 'six' (/home/toor/.local/lib/python3.8/site-packages/six.py)

I tried install from the aur git flask package  but for that i get file conflicts
error: failed to commit transaction (conflicting files)
  -> python-werkzeug
  -> python-itsdangerous
  -> python-click
for these,
Is it okay to remove by rm -rf /usr/lib/python3.8/site-packages/click
and install aur packages??

Also why cant i juse use pip -r install requirements.txt
For a very big file i cant go to each aur package and download right
There must be a easier way?

Last edited by si67 (2020-10-24 08:02:25)

Offline

#2 2020-10-24 03:03:29

solskog
Member
Registered: 2020-09-05
Posts: 415

Re: [Solved] Cant install pip packages?

How about

# pacman -S python-flask

Offline

#3 2020-10-24 03:06:04

si67
Member
Registered: 2020-09-06
Posts: 26

Re: [Solved] Cant install pip packages?

i get the same error
error: failed to commit transaction (conflicting files)

Offline

#4 2020-10-24 03:10:43

Scimmia
Fellow
Registered: 2012-09-01
Posts: 11,544

Re: [Solved] Cant install pip packages?

Because you've made a mess of you python environment by using pip as root. IIRC, this was covered in the wiki.

Offline

#5 2020-10-24 03:12:00

si67
Member
Registered: 2020-09-06
Posts: 26

Re: [Solved] Cant install pip packages?

oh can i get a link?


i was able to install flask by

# pacman -S python-flask --overwrite "*"

Last edited by si67 (2020-10-24 03:12:54)

Offline

#6 2020-10-24 03:26:25

loqs
Member
Registered: 2014-03-06
Posts: 17,321

Re: [Solved] Cant install pip packages?

https://wiki.archlinux.org/index.php/Py … management

There are several ways to install Python packages on Arch Linux:

    Official repositories and AUR — A large number of popular packages are available in the Arch repositories. This is the preferred way to install system-wide packages.
    pip — The official package installer for Python. You can use pip to install packages from the Python Package Index and other indexes.

    https://pip.pypa.io/ || python-pip

    Conda — An open source package management system and environment management system, originally created for Python programs. You can use Conda to install packages from the Anaconda repositories.

    https://docs.conda.io/projects/conda/ || anacondaAUR

When installing packages from sources other than the official repositories and AUR, it is recommended to use a virtual environment (or Conda environment management) to prevent conflicts with system packages in /usr. Alternatively, pip install --user can be used to install packages into the user scheme instead of /usr.

Emphasis added.

Offline

#7 2020-10-24 03:33:36

si67
Member
Registered: 2020-09-06
Posts: 26

Re: [Solved] Cant install pip packages?

Well im still having this error even for pip install --user
How do i correct this

toor@friday ~: $ pip install --user django
Traceback (most recent call last):
  File "/usr/bin/pip", line 33, in <module>
    sys.exit(load_entry_point('pip==20.1.1', 'console_scripts', 'pip')())
  File "/usr/lib/python3.8/site-packages/pip/_internal/cli/main.py", line 73, in main
    command = create_command(cmd_name, isolated=("--isolated" in cmd_args))
  File "/usr/lib/python3.8/site-packages/pip/_internal/commands/__init__.py", line 104, in create_command
    module = importlib.import_module(module_path)
  File "/usr/lib/python3.8/importlib/__init__.py", line 127, in import_module
    return _bootstrap._gcd_import(name[level:], package, level)
  File "<frozen importlib._bootstrap>", line 1014, in _gcd_import
  File "<frozen importlib._bootstrap>", line 991, in _find_and_load
  File "<frozen importlib._bootstrap>", line 975, in _find_and_load_unlocked
  File "<frozen importlib._bootstrap>", line 671, in _load_unlocked
  File "<frozen importlib._bootstrap_external>", line 783, in exec_module
  File "<frozen importlib._bootstrap>", line 219, in _call_with_frames_removed
  File "/usr/lib/python3.8/site-packages/pip/_internal/commands/install.py", line 24, in <module>
    from pip._internal.cli.req_command import RequirementCommand, with_cleanup
  File "/usr/lib/python3.8/site-packages/pip/_internal/cli/req_command.py", line 20, in <module>
    from pip._internal.operations.prepare import RequirementPreparer
  File "/usr/lib/python3.8/site-packages/pip/_internal/operations/prepare.py", line 15, in <module>
    from pip._internal.distributions import (
  File "/usr/lib/python3.8/site-packages/pip/_internal/distributions/__init__.py", line 2, in <module>
    from pip._internal.distributions.wheel import WheelDistribution
  File "/usr/lib/python3.8/site-packages/pip/_internal/distributions/wheel.py", line 5, in <module>
    from pip._internal.utils.wheel import pkg_resources_distribution_for_wheel
  File "/usr/lib/python3.8/site-packages/pip/_internal/utils/wheel.py", line 12, in <module>
    from pip._vendor.six import PY2, ensure_str
ImportError: cannot import name 'ensure_str' from 'six' (/home/toor/.local/lib/python3.8/site-packages/six.py)

Offline

#8 2020-10-24 04:51:10

loqs
Member
Registered: 2014-03-06
Posts: 17,321

Re: [Solved] Cant install pip packages?

ImportError: cannot import name 'ensure_str' from 'six' (/home/toor/.local/lib/python3.8/site-packages/six.py)

Remove that version of six so the system version is used instead.

Offline

#9 2020-10-24 05:54:52

si67
Member
Registered: 2020-09-06
Posts: 26

Re: [Solved] Cant install pip packages?

Thanks i removed the six.py file and it works but

toor@friday ~: $ pip install requests
Defaulting to user installation because normal site-packages is not writeable
Requirement already satisfied: requests in /usr/lib/python3.8/site-packages (2.24.0)
Requirement already satisfied: chardet>=3.0.2 in /usr/lib/python3.8/site-packages (from requests) (3.0.4)
Requirement already satisfied: idna>=2.5 in /usr/lib/python3.8/site-packages (from requests) (2.10)
Requirement already satisfied: urllib3>=1.21.1 in /usr/lib/python3.8/site-packages (from requests) (1.25.10)
toor@friday ~: $ python -m pip install requests
Defaulting to user installation because normal site-packages is not writeable
Requirement already satisfied: requests in /usr/lib/python3.8/site-packages (2.24.0)
Requirement already satisfied: chardet>=3.0.2 in /usr/lib/python3.8/site-packages (from requests) (3.0.4)
Requirement already satisfied: idna>=2.5 in /usr/lib/python3.8/site-packages (from requests) (2.10)
Requirement already satisfied: urllib3>=1.21.1 in /usr/lib/python3.8/site-packages (from requests) (1.25.10)

Defaulting to user installation because normal site-packages is not writeable
what do i do for this

Offline

#10 2020-10-24 07:36:05

Mr.Elendig
#archlinux@freenode channel op
From: The intertubes
Registered: 2004-11-07
Posts: 4,092

Re: [Solved] Cant install pip packages?

Use venv, not user installs.


Evil #archlinux@libera.chat channel op and general support dude.
. files on github, Screenshots, Random pics and the rest

Offline

#11 2020-10-24 08:02:01

si67
Member
Registered: 2020-09-06
Posts: 26

Re: [Solved] Cant install pip packages?

OKays

Offline

#12 2020-10-24 19:05:37

flyingscorpio
Member
Registered: 2020-06-04
Posts: 34

Re: [Solved] Cant install pip packages?

si67 wrote:

Defaulting to user installation because normal site-packages is not writeable
what do i do for this

That's not an error but a warning. It's basically doing the same as when you do

pip install --user

because you didn't use use sudo so pip can't write to /usr, which is exactly what you want.
Never use sudo with pip, that will conflict with pacman and cause problems.
Always install in a venv or in your /home if you need the package globally.

By the way, you might want to check the pacman wiki page about removing files not owned by pacman (those created by pip in /usr). If they haven't already, they will cause problems.

Offline

#13 2020-10-25 00:41:40

eschwartz
Fellow
Registered: 2014-08-08
Posts: 4,097

Re: [Solved] Cant install pip packages?

si67 wrote:

Thanks i removed the six.py file and it works but

toor@friday ~: $ pip install requests
Defaulting to user installation because normal site-packages is not writeable
Requirement already satisfied: requests in /usr/lib/python3.8/site-packages (2.24.0)
Requirement already satisfied: chardet>=3.0.2 in /usr/lib/python3.8/site-packages (from requests) (3.0.4)
Requirement already satisfied: idna>=2.5 in /usr/lib/python3.8/site-packages (from requests) (2.10)
Requirement already satisfied: urllib3>=1.21.1 in /usr/lib/python3.8/site-packages (from requests) (1.25.10)
toor@friday ~: $ python -m pip install requests
Defaulting to user installation because normal site-packages is not writeable
Requirement already satisfied: requests in /usr/lib/python3.8/site-packages (2.24.0)
Requirement already satisfied: chardet>=3.0.2 in /usr/lib/python3.8/site-packages (from requests) (3.0.4)
Requirement already satisfied: idna>=2.5 in /usr/lib/python3.8/site-packages (from requests) (2.10)
Requirement already satisfied: urllib3>=1.21.1 in /usr/lib/python3.8/site-packages (from requests) (1.25.10)

Defaulting to user installation because normal site-packages is not writeable
what do i do for this

  • You did not specify pip install --user, but pip recognized it could not install to /usr/lib/python3.8/site-packages and warned you it would act as if you specified --user

  • The requests module existed on your system, so it told you "ok done, but FYI we didn't need to do anything"

  • You then repeated the pip command using python -m pip, for identical effect, since "pip" and "python -m pip" are exactly the same thing, but the latter makes sure to use the same version of python as /usr/bin/python, while the former only uses the same version of python as /usr/bin/python because Arch Linux configures it to be so.


Managing AUR repos The Right Way -- aurpublish (now a standalone tool)

Offline

Board footer

Powered by FluxBB