1

I've been facing a problem for some time and I'm not finding a solution. At the company where I work, I'm trying to implement Python, but when I run the conventional command "Pip install pandas" in my vscode terminal, it gives an error because the company blocks the installation of external libraries, so it's as if I had to install these libraries on a PC without connection.

How should I follow this procedure?

  • I downloaded the .whl library from PyPi: pandas-1.5.2-cp310-cp310-win_amd64.whl
  • ran pip install pandas-1.5.2-cp310-cp310-win_amd64.whl -f ./ --no-index --no-deps

Ok, the installation was successful. But this installation of pandas by cmd is not going to my system, because when trying to import pandas in my vscode it is not running, as if it had not been installed.

Would it be possible for me to download several libraries and leave them located in a folder where everyone in the company can use them? example using a function where I declare my path where all the libraries will be, and then I import them from there??

Michael M.
  • 10,486
  • 9
  • 18
  • 34
Deforceh
  • 11
  • 3
  • 1
    @Michael M. they blocked it to prevent us from leaving anything from the internet, so it blocks everything so it was recommended that we download files that we know are reliable and leave them stored there – Deforceh Dec 28 '22 at 01:01
  • so I need a solution that I can download these libraries and take to my pc in the area to leave it stored there for everyone to be able to use. – Deforceh Dec 28 '22 at 01:03
  • 1
    Ok, fair reason. Are you sure that VSCode and your terminal are using the same Python installation? Sometimes VSCode will install its own verison of Python (and pip). – Michael M. Dec 28 '22 at 01:03
  • So I don't know how I could see that but I believe so. vscode uses Python which is installed on my machine – Deforceh Dec 28 '22 at 01:06
  • 1
    There's some guidance [here](https://stackoverflow.com/a/46071447/1424875) that can help check what paths each installation uses. – nanofarad Dec 28 '22 at 01:07
  • but when using this method to install these libraries, I'm doing the following. I create a folder containing these .whl files and in my cmd I enter G:\Librarys inside it, when entering it I execute the command, but even with successful installation, it is not playing this library inside the Python folder installed in my system – Deforceh Dec 28 '22 at 01:10
  • I always install my libraries in the script folder of where your python.exe is installed at. So as long your python.exe is on the environment path, any code editors can access them – Sin Han Jinn Dec 28 '22 at 01:31
  • btw, you are tagging jupyter notebook? Are you using it too? – Sin Han Jinn Dec 28 '22 at 01:33
  • I would imagine if you want to store libraries in some arbitrary location (not one where python normally looks for modules), you will want to update your python path so that they can be found. This could probably be done when VSCode starts up, or by other means. – topsail Dec 28 '22 at 01:38
  • 1
    @Sin Han Jinn I use Jupyter inside vscode to better visualize my python graphics – Deforceh Dec 28 '22 at 01:45
  • @Deforceh I see.. – Sin Han Jinn Dec 28 '22 at 01:46
  • @vela superior in vscode I can only open the folder where I'm going to work on my project, and Python itself only has the default path located in my C: directory, I don't know how I could make Python in my vscode pull the libraries in another path. If anyone has any ideas I'm listening – Deforceh Dec 28 '22 at 01:55

1 Answers1

0

First confirm if you can run any python commands from VSCode. If the answer is yes, you can proceed to install your .whl file in python script folder.

Look for the Scripts folder enter image description here

Add in your .whl file in this folder

Then open the folder, select the path, press Ctrl+D to display full path, type in cmd to open command prompt to this directory

enter image description here enter image description here

Then just run your pip install here and you should be good to go enter image description here

Remember the key is that your VSCode must be able to find Python.exe. If it can't from the start, you will need to add your python directory to PATH in environment variable

Sin Han Jinn
  • 574
  • 3
  • 18
  • this information sounds good to me. I haven't tried to do this yet, but I'm not at my workplace to test it, I'll test it tomorrow when I'm at my workplace and I'll get back to you ok – Deforceh Dec 28 '22 at 01:48
  • now when you mention you're using jupyter extension in VSCode this might not apply if the paths are different. For example if you are using anaconda it would have a different path where it saves its libraries. you might need to do some digging. – Sin Han Jinn Dec 28 '22 at 01:52
  • I don't think so, in this case I don't use anaconda. I only have vscode on my pc, and python 3.10.6 (Jupyter only as an extension), I don't think it will change anything in the process – Deforceh Dec 28 '22 at 01:57
  • Good morning @Sin Han Jinn, even doing as suggested above, it returns the following ERROR: Could not install packages due to an OSError: HTTPSConnectionPool(host='files.pythonhosted.org', port=443): Max retries exceeded with url: /packages/3d/19/4de17f0d5cf5a0d87aa67532d4c2fa75e6e7d8df13c27635ff40fa6f4b76/pytz-2022.7-py2.py3-none-any.whl (Caused by SSLError(SSLCertVerificationError(1, '[SSL: CERTIFICATE_VERIFY_FAILED] certificate verify failed: self signed certificate in certificate chain (_ssl.c:997)'))) – Deforceh Dec 29 '22 at 12:00
  • OBS: my vscode interpreter is at:"C:\Users\u502724\AppData\Local\Programs\Python\Python310\python.exe" is this correct or should i change it? since my libraries are in the Scripts folder – Deforceh Dec 29 '22 at 12:30
  • I was able to install the libraries with: "pip install numpy-1.24.1-cp310-cp310-win_amd64.whl -f ./ --no-index --no-deps" and others that I need to use, but again my import in vscode does not work – Deforceh Dec 29 '22 at 12:55