-1

Whenever I run pip install <PACKAGE-NAME>. cmd throws an error. It is only when I run pip install <PACKAGE-NAME> --user the command prompt works properly without any error.

For instance, when I run pip3 install runway-python I get, ERROR:

Exception: Traceback (most recent call last): File "c:\program files (x86)\microsoft visual studio\shared\python37_64\lib\site-packages\pip_internal\cli\base_command.py", line 186, in _main status = self.run(options, args) File "c:\program files (x86)\microsoft visual studio\shared\python37_64\lib\site-packages\pip_internal\commands\install.py", line 258, in run isolated_mode=options.isolated_mode, File "c:\program files (x86)\microsoft visual studio\shared\python37_64\lib\site-packages\pip_internal\commands\install.py", line 604, in decide_user_install if site_packages_writable(root=root_path, isolated=isolated_mode): File "c:\program files (x86)\microsoft visual studio\shared\python37_64\lib\site-packages\pip_internal\commands\install.py", line 549, in site_packages_writable test_writable_dir(d) for d in set(get_lib_location_guesses(**kwargs)) File "c:\program files (x86)\microsoft visual studio\shared\python37_64\lib\site-packages\pip_internal\commands\install.py", line 549, in test_writable_dir(d) for d in set(get_lib_location_guesses(**kwargs)) File "c:\program files (x86)\microsoft visual studio\shared\python37_64\lib\site-packages\pip_internal\utils\filesystem.py", line 140, in test_writable_dir return _test_writable_dir_win(path) File "c:\program files (x86)\microsoft visual studio\shared\python37_64\lib\site-packages\pip_internal\utils\filesystem.py", line 153, in _test_writable_dir_win fd = os.open(file, os.O_RDWR | os.O_CREAT | os.O_EXCL) PermissionError: [Errno 13] Permission denied: 'c:\program files (x86)\microsoft visual studio\shared\python37_64\Lib\site-packages\accesstest_deleteme_fishfingers_custard_1epdye'

it's fine when I append the code with --user. is there a way to fix this? I mean so that I don't have to append every pip install command with a --user.

skaul05
  • 2,154
  • 3
  • 16
  • 26

2 Answers2

0

Your python installation (which seems to have come with visual studio) is under 'c:\program files (x86), which is by default only writeable with admin privileges. In order to get your pip install working, you will need to launch your cmd with admin privileges.

FlyingTeller
  • 17,638
  • 3
  • 38
  • 53
  • I tried cmd with admin privileges. It worked fine. do you have any other solution other than opening cmd in admin mode? – user435715 Apr 15 '20 at 14:42
  • If you don't want to use `--user` each time and don't want to bother opening in admin mode each time, I only see two other ways: Modify the security settings so normal users have rw rights on `c:\program files (x86)\microsoft visual studio\shared\python37_64` OR uninstall the visual studio python installation and instead download and install python yourself and install it for your user only – FlyingTeller Apr 15 '20 at 14:48
  • I don't want to recommend to mess with your security settings, so I would see option 2 as my recommendation if you want to get rid of bothering with the restrictions – FlyingTeller Apr 15 '20 at 14:49
-3

I suggest uninstalling and reinstalling pip:

sudo apt remove python-pip
sudo apt install python-setuptools
sudo easy_install -U pip

(Or the same with pip3 if that is what you're using)

amm
  • 43
  • 1
  • 1
  • 7
  • OP is using windows, so no `sudo`, also, why do you think reinstalling will fix the issue that the `site-packages` requires admin privileges to write to – FlyingTeller Apr 15 '20 at 14:28