6

this is what I'm using to install packages, the only one that works is requests

pip._internal.main(['install', 'requests'])
pip._internal.main(['install', 'lxml'])
pip._internal.main(['install', 'cssselect'])
pip._internal.main(['install', 'selenium'])

this is the error message that i get in the console

Requirement already satisfied: requests in c:\users\user\appdata\local\programs\python\python37-32\lib\site-packages (2.20.1)
Requirement already satisfied: chardet<3.1.0,>=3.0.2 in c:\users\user\appdata\local\programs\python\python37-32\lib\site-packages (from requests) (3.0.4)
Requirement already satisfied: certifi>=2017.4.17 in c:\users\user\appdata\local\programs\python\python37-32\lib\site-packages (from requests) (2018.11.29)
Requirement already satisfied: urllib3<1.25,>=1.21.1 in c:\users\user\appdata\local\programs\python\python37-32\lib\site-packages (from requests) (1.24.1)
Requirement already satisfied: idna<2.8,>=2.5 in c:\users\user\appdata\local\programs\python\python37-32\lib\site-packages (from requests) (2.7)
Collecting lxml
  Using cached https://files.pythonhosted.org/packages/43/c7/e088bf0f4f81e6b366cc2de12939c559b588b9525ad76215d122e69151ed/lxml-4.2.5-cp37-cp37m-win32.whl
Could not install packages due to an EnvironmentError: [Errno 2] No such file or directory: 'C:\\Users\\user\\AppData\\Local\\Temp\\pip-req-tracker-047sxufq\\9dca403282533c33ca73fe9ecbdb1b605aeffa273ec0704ef517f834'

Collecting cssselect
  Using cached https://files.pythonhosted.org/packages/7b/44/25b7283e50585f0b4156960691d951b05d061abf4a714078393e51929b30/cssselect-1.0.3-py2.py3-none-any.whl
Could not install packages due to an EnvironmentError: [Errno 2] No such file or directory: 'C:\\Users\\user\\AppData\\Local\\Temp\\pip-req-tracker-047sxufq\\e5cecb9a9f004e9bd84aa92925e0dc6e8458127d14eb08f37c4e2d0f'

Collecting selenium
  Using cached https://files.pythonhosted.org/packages/80/d6/4294f0b4bce4de0abf13e17190289f9d0613b0a44e5dd6a7f5ca98459853/selenium-3.141.0-py2.py3-none-any.whl
Could not install packages due to an EnvironmentError: [Errno 2] No such file or directory: 'C:\\Users\\user\\AppData\\Local\\Temp\\pip-req-tracker-047sxufq\\b3025a26893a7657747ef91c7e8a7d138021b8a645639c56cd0046c5'

i'm fairly new to python and just coding in general, i don't really know what these errors mean, and i couldn't find anything on google that i understood, so any help at all would be appreciated.

this is in visual studio code and on python 3.7.1

Hunter Chen
  • 65
  • 1
  • 6
  • 1
    There is no reason at all that I can see to use `pip._internal.main(['install', 'requests']` and the rest. Open cmd prompt and type `pip install `. If you're new to python, it's curious that you found this fringe approach that you're using; did you have issues with the standard approach? – roganjosh Dec 01 '18 at 20:06
  • @roganjosh when i used command prompt it said that pip is not recognized so i kind of just googled a bunch of stuff and i found that, which worked for requests but not the other stuff, and i wanted to be able to use this on multiple computers easily and i this was the best way i found. – Hunter Chen Dec 01 '18 at 20:08
  • Ok, this is not the correct fix. Did you install Anaconda or just regular python? – roganjosh Dec 01 '18 at 20:09
  • @roganjosh just regular python – Hunter Chen Dec 01 '18 at 20:10
  • https://stackoverflow.com/questions/23708898/pip-is-not-recognized-as-an-internal-or-external-command – phd Dec 01 '18 at 20:11
  • https://stackoverflow.com/search?q=%5Bpip%5D+is+not+recognized – phd Dec 01 '18 at 20:11
  • @phd i got it working using command prompt! i'd still like to know why this error appears though.. – Hunter Chen Dec 01 '18 at 20:15
  • Take the first of @phd links. That's the correct way to fix this. Your approach is fraught with issues. – roganjosh Dec 01 '18 at 20:15
  • @roganjosh i reinstalled python and i checked add python to environment variables and now it works, but I'd still like to know why this error appears when i run it like this. – Hunter Chen Dec 01 '18 at 20:17
  • `pip._internal` should ring alarm bells. The leading underscore is the universal python syntax for "don't use this variable or invoke this method directly". How _exactly_ it fails, I don't know, but the point is that you shouldn't be accessing it in the first place unless you _know_ what you're doing (nothing in Python is private, the best you can do is stick a "don't touch this" sign to methods and variables) – roganjosh Dec 01 '18 at 20:20
  • @roganjosh alright ill keep that in mind, thank you for your help – Hunter Chen Dec 01 '18 at 20:22

1 Answers1

0

I know this is coming late, but I guess this will help someone else who is facing a similar issue.

In the path:

C:\\Users\\user\\AppData\\Local\\Temp\\pip-req-tracker-047sxufq\\b3025a26893a7657747ef91c7e8a7d138021b8a645639c56cd0046c5

The "AppData" folder and its contents are probably marked as "Hidden" and/or "Read only" by the Windows, unticking those and designating them as normal folders might help.

This is the only solution that helped me out. Please try it out and comment.

Abhishek V
  • 87
  • 2