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

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.

Related

Installing py2exe python module offline

I've been trying to install the py2exe module (for Python 3) offline (it's a stand-alone network) without without installing any dependencies first (I couldn't find a list of dependencies anywhere).
When I try to install it, it runs into a module exception :
no module named py2exe_distutils
The file is in a .tar.gz format.
I use the pip install file in cmd while being in the file directory.
I would appreciate any help regarding this.
I think you need this:
https://github.com/py2exe/py2exe/releases/tag/v0.10.4.0
this file contain the offline setup 😁
image

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.

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
...

Pip error when trying to install module

I'm trying to install PyDrive [a wrapper library of the google drive api for python] and pip is giving me this error. It did the same thing when trying to install things like matplotlib or mega.py [a mega.nz api for python].
Here's the error:
Anyone got a clue what's going on?
Cheers
You could try renaming that pip.py to something else.
There is a library called pip somewhere on your system (and it may also be bundled within pip.exe). That is different from the "entry point" script that actually runs pip from the command line. When you run pip, it will try to import the library called pip. If there is a script called pip.py in the Scripts directory (representing the entry-point script, not the library), it may import that instead of the real library. If this is indeed the problem, renaming pip.py to something else will remove the name conflict and allow pip to properly import the library it needs.
I'm not sure how you wound up with pip.py in your Scripts directory in the first place. I don't think it should be there. My Python installation on Windows doesn't have it.

Load and read ply files with Pymesh

I am trying to load/read a ply file using PyMesh and this line command:
mesh = pymesh.load_mesh("model.obj")
as it is in http://pymesh.readthedocs.io/en/latest/basic.html.
But this gives me an error "AttributeError: 'module' object has no attribute 'load_mesh'".
Am I doing anything wrong? Also I want to know if PyMesh really allows to visualize in 3d the objects.
Thank you.
If you installed with pip, you might not have gotten the pymesh module you were intending to use. Since you're looking for the load_mesh() method, you'll want to use this installation guide: http://pymesh.readthedocs.io/en/latest/installation.html.
There are actually two modules named pymesh.
Pymesh by Takuro Wada
If you install pymesh using pip you are installing this one which has the following GitHub page.
It reads: .sty and .obj
Pymesh by Qingnan Zhou
If you want to install http://pymesh.readthedocs.io/en/latest/ you have to follow the installation guidelines here.
It is more complex, I never manage to get it working, but it should read also .ply.
On a side note, meshio (one of my projects) now supports PLY as well. Install with
pip3 install meshio
and use on the command line like
meshio-convert in.ply out.vtk
or from within Python like
import meshio
mesh = meshio.read("in.ply")
# mesh.points, mesh.cells, ...
Since you are look for load_mesh() method, i think that you are looking for this library.
This is the related doc.
If true, you have to install pymesh2
pip install pymesh2
Otherwise you have to follow the instructions contained in that page as already suggested, but they are more complex.
Either you have not imported the pymesh library
import pymesh
OR
You have a file named pymesh.py in your directory where you are executing this file.
If this is the case, then rename the file to some other name.

Categories

Resources