Sunday, September 29, 2024

If your python environment does not have pip installed. What then?

Over a period of time, there was some computer problem which needed complete recovery. Before this event, I had installed PyCharm and had everything working without problem and I had even installed PIL library from within PyCharm. However, after the recovery, I lost some of the files.

Besides, PIL I wanted to install other libraries to work with images. When I tried to open an existing project in PyCharm, I encountered errors.

All Python packages were absent and the program was asking me for a Python interpreter.

What happened to my python?

Before proceeding to other image related libraries, I had to fix this problem.

If your Python environment does not have pip installed you need to install pip first. There are two ways to install pip supported by the pip's maintainers:

ensurepip       -------->run py -3 -m ensurepip

or run get-pip.py------->run get-pip.py using python interpreter

Because of the recovery created problem, I did not have python interpreter according to PyCharm (as shown in the first image above).

I need to install python even before I can install pip.

I tried to find python.dll which I could not as I had lost it during recovery.

Finally, I found it in the Windows.old folder [C:\Windows.old07042024\Users\hoden\AppData\Local ]

I copied the python.exe from the windows.old folder to Windows/system32.

 I tried to run from the command-line with administrative privileges:

-------

C:\Users\hoden\OneDrive\Desktop\PyCharm\PIL>python get-pip.py

Could not find platform independent libraries <prefix>

Collecting pip

  Downloading pip-24.2-py3-none-any.whl.metadata (3.6 kB)

Downloading pip-24.2-py3-none-any.whl (1.8 MB)

   ---------------------------------------- 1.8/1.8 MB 33.0 MB/s eta 0:00:00

Installing collected packages: pip

  WARNING: The scripts pip.exe, pip3.12.exe and pip3.exe are installed in 'C:\Users\hoden\OneDrive\Desktop\PyCharm\PIL\Scripts' which is not on PATH.

  Consider adding this directory to PATH or, if you prefer to suppress this warning, use --no-warn-script-location.

Successfully installed pip-24.2

-----------

I ran into another problem because of the 'Onedrive'. Permit me to call it 'oneDrive" interference.

Finally, I copied the python folder into Windows\System32 of local computer and restarted the computer(laptop). The problem was resolved as seen in PyCharm.

Finally, both the Python Console and the Python packages are all back in PyCharm.

More here:




 

No comments: