0

i've installed a python project, and it imports modules(Like almost every project). The problem is when i want to install them(because i haven't got the modules), for example: In the project is imported a module called "a" but when i go and install "a" with pip install a, it says ERROR: Could not find a version that satisfies the requirement a (from versions: none) ERROR: No matching distribution found for a. How could i know the name of the module that is imported in that python project?

Edit: btw i just found out the module that the project uses comes in the zip where the python project is. How could i install it so it works?

8
  • What is an example of a library that you cannot install? Can you install any libraries with pip? Commented Dec 17, 2021 at 18:12
  • @blackbrandt Yes i can install libraries with pip. Commented Dec 17, 2021 at 18:22
  • How did you install this python project? It should have come with a requirements.txt file indicating which packages it relies upon, so that they can be installed by pip at the same time you're installing the main project. Commented Dec 17, 2021 at 18:25
  • @MattDMo It comes with the modules in the zip i think, because there are py files that have the names imported in the main project Commented Dec 17, 2021 at 18:28
  • Well, if it comes with .py files that are named according to the imports, then what's the problem? Those are internal imports; they're not looking for an external module that you need to install... Commented Dec 17, 2021 at 18:34

2 Answers 2

1

All pip packages are listed here. If you want to import a module called a inside a python script, the command to install it could be sometimes pip install b. Because the name of the stored package can varied from the python import name. To find how to install it the best is to get the pypi url of your package. You can googling the python error ModuleNotFoundError: No module named 'dgvd', it always show you the pypi url in top links.

The good practice in a project is to have a txt file called requirement.txt that you create in bash using this command:

pip freeze > requirement.txt 

Then install all packages in once using:

pip install -r requirement.txt 
Sign up to request clarification or add additional context in comments.

2 Comments

PyPI is not the only package repository, it's just the most commonly used.
Its unfortunate your best method for this is googling. I find people mentioning module x somewhere when trying to find a way to do something, I run pip install x and get errors. Have to google to find out its actually called y. Then when I want to import it, I find actually called z when you import.
0

For installing from zip simply use:

pip install *.zip 

or specify the path directly:

pip install <path to .zip> pip install ./my-archive.zip 

Same applies for a tarball or any other format. It can be even a folder. However, it has to include a proper setup.py or other mechanism for pip to install it and pip has to support the packaging format (be it archive, networking protocol, version control system (git prefix), etc).

pip install ./my-folder pip install ./ pip install . pip install .. etc 

If, however, there is no setup.py present, you'll need to simply copy-paste the files somewhere where your project/module resides (or set PYTHONPATH or sys.path to that folder) to be able to import them. See this or this question for more.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.