Import youtube-dl directly from git repository into ipython - python

I have forked and checked out the youtube-dl repository from github. I would like to import youtube-dl directly from my git directory without having to install it, to test my changes in the code. Is this possible? How do I do this?

You can simply cd into the project root and then import youtube_dl.
To clarify that this is the version you want instead of pip's version, look at the value of youtube_dl.__file__ to see where the module is located:
In [1]: import youtube_dl
In [2]: youtube_dl.__file__
Out[2]: 'C:\\Users\\Me\\Documents\\youtube-dl\\youtube_dl\\__init__.py'

Take a look at the project readme, the developer instruction section is what you are searching for.
If you want to separate your work in the directory from the system version of the module you could look at virtualenv, a tool to isolate your projects dependencies.

Related

How to install "util" (not utils) module

I am trying to run the example found in the README of the PyLSCI package. It references a module util, so I am trying to install that through Conda, but it is not working. I have tried typing conda install util into the Anaconda Prompt, but I get an error that says:
PackagesNotFoundError: The following packages are not available from current channels
How can I install this module?
Additional Details
Windows OS
Anaconda Python distribution
There is no such "util" package. Seems like a classic grad-ware pattern: an old example is shown in the README.md referencing a local util.py file, that is kept in the release even though it is no longer relevant. Please file an issue on the GitHub repository to ask the author to update the documentation.
The mentioned util.py package is only used for the demo.ipynb, and it is exemplarly for any custom logic that is required to convert your speckle data to NumPy arrays, which is out of scope of PyLSCI.
See this GitHub issue for details, where I clearified this with Briget
The PyLSCI package itself doesn't rely on the mentioned util.py to work properly, as long as you provide the speckle data as NumPy arrays.
To make that more evident, I renamed the module to my_utils.py, and moved it with the demo.ipynb notebook to the binder directory of the repo, also see the latest release notes for further changes.

Importing module from Github to use in Python

I'm a beginner in Python and I have no experience with GitHub at all. I want to import the module semsimlib from the following URL: https://github.com/timvdc/semsimlib
I have looked on the internet for help on how to do this but most of it is very unclear and doesn't seem to work for me. Can anyone provide a detailed explanation on how to do this in a easy way?
It looks the repo does not provide appropriate scripts to simply install the package. There is no setup.py file and there is no distribution on pypi.
What you can do is go to site-packages folder inside your python installation or inside your virtual environment. Then run git clone https://github.com/timvdc/semsimlib. You should now be able to import semsimlib. Keep in mind that you will also have to install all the other dependencies your self one by one since there is also no requirements file.
You can also clone the repo into any folder on your computer and at the top of your script put:
import sys
sys.path.append("path/to/semsimlib/folder")
semsimlib will now be importable. However, I would try to get it to work with the first method.

Can you install a python file from git as a module?

I am currently interested in installing the following git repository:
https://github.com/CodeReclaimers/neat-python/tree/master/examples/xor.
It contains a file called visualize.py and I would love to just install and use it as a module (e.g. numpy). However, I'm not sure how if it is possible to do this and was, therefore, hoping anyone could clarify this for me.
I have tried:
pip install git+https://github.com/CodeReclaimers/neat-python/tree/master/examples/xor
Any help would be appreciated!
Edit:
I was able to clone the entire repo:
pip install git+https://github.com/CodeReclaimers/neat-python.git
Does this mean I should be able to use all the files available in this repository as a module or is there something I'm still missing? I still cannot use visualize as a module. Thanks!
If you are able to clone the library to the same directory, you can simply import the python file without pip installing as module.
For instance if the file is called myFile.py, you can call the following and the entire file is executed and functions within can be used.
import myFile
1- open directory with modules
example : c:\users\james\appdata\local\programs\python\python39\lib
2-New python file created
example : visualize.py
3- save the python file.

Is there a way to get directory package dependencies in python?

I am aware that pip freeze > requirements.txt exists, yet that that prints out my system packages, of which only a few my directory/ project needs.
I am not using a virtualenv so I'm pretty sure I can't print out local packages like that.
I also know that pipdeptree exsists but I also don't see how that solves my problem?
I believe tools like the following could help:
pipreqs
pigar
As far as I can tell, these tools read the code in the directory and try to figure out the dependencies required based on the import statements they found in the code.
Related:
https://stackoverflow.com/a/61202584
https://stackoverflow.com/a/61540466
https://stackoverflow.com/questions/61143402/how-to-generate-requirements-txt-for-given-py-sources-folder-or-specific-py-file
https://stackoverflow.com/a/31684470

Installing a github package without setup.py?

I am trying to install https://github.com/ExaVault/evapi-python.git using pip, but it doesn't have a setup.py so how am I supposed to use it? I want to use the packages it contains, but with no setup.py how am I supposed to use it?
Just an unfinished, broken package, it isn't supposed to be installed by Python tools. Install it manually — clone the repo and copy files to site-packages.
And send them a bug report. Or better yet a pull-request.
Upd. Oh, I see, you've sent a bug report alredy, nice!
Installing it looks like a manual job, but you can still use it. Download it as zip here https://github.com/ExaVault/evapi-python/archive/master.zip, extract, go to evapi-python-master folder, go to src, and simply place your code there.
import V1Api
import ApiClient
...

Categories

Resources