Python Forum
to get a list of pip packages that were installed
Thread Rating:
  • 1 Vote(s) - 5 Average
  • 1
  • 2
  • 3
  • 4
  • 5
to get a list of pip packages that were installed
#13
(Jun-24-2022, 11:41 PM)Skaperen Wrote: could you do pip_lst.append(line.split(None,1)[0]) to get a simpler list?
Like this pip_lst.append(line.split()[0])
But when i think about should not use pip list in poetry,as get stuff that not need as pytest modules.
Like this.
poetry export --without-hashes --format=requirements.txt > requirements.txt
requirements.txt
numpy==1.23.0; python_version >= "3.10"
pandas==1.4.3; python_version >= "3.8"
python-dateutil==2.8.2; python_version >= "3.8" and python_full_version < "3.0.0" or python_full_version >= "3.3.0" and python_version >= "3.8"
pytz==2022.1; python_version >= "3.8"
six==1.16.0; python_version >= "3.8" and python_full_version < "3.0.0" or python_full_version >= "3.3.0" and python_version >= "3.8"
Then if need even simpler list don't known why this in needed all,parse like this.
poetry_lst = []
with open('requirements.txt') as f:
    for line in f:
        line = line.split('==')
        poetry_lst.append(line[0])

print(poetry_lst)
Output:
['numpy', 'pandas', 'python-dateutil', 'pytz', 'six']
So remember this is the modules Pandas need to run,as started with just a environment for Pandas poetry add pandas.
Reply


Messages In This Thread
RE: to get a list of pip packages that were installed - by snippsat - Jun-25-2022, 11:38 AM

Possibly Related Threads…
Thread Author Replies Views Last Post
  what pip command can list installed files for a name package? Skaperen 3 2,193 Aug-04-2020, 10:15 PM
Last Post: Skaperen
  pip list available packages Skaperen 16 36,716 Oct-31-2017, 12:36 AM
Last Post: Skaperen

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020