For a class, I need to be able to use this github library: https://github.com/matsselen/pyolab. I am struggling to download/install it in a way that actually works. I am using anaconda for this and commands I've tried include:
conda install pyolab
pip install pyolab
conda install source_code_file_path
pip install -e git+https://github.com/matsselen/pyolab#egg=pyolab
I've saved the source code into anaconda's 'pkgs' folder and in my root folder.
I really don't know much about creating packages but in my searching, I found that the issue might be that there is no setup.py file included in the code on github. I tried to build my own but I can't get that to work. Here is the code I have for that:
from setuptools import setup
setup(name='pyolab',
version='master',
description='IOLab code'
author='mats selen'
packages=['pyolab']
)
Also, I am being required to use the python 2.7 version of the package instead of the newer python 3 version.
Can anyone help point me in the right direction to get this working?
No need to pip-install repository, any python scripts can be used directly from any regular files/dirs on file system.
Just clone the repository:
git clone https://github.com/matsselen/pyolab
and then use sys.path to specify location of library's scripts and import them:
import sys
sys.path.append('./pyolab/PyOLabCode/')
# all dirs from sys.path are scanned by Python when you do import
# and the first matched dir where the module is found is used
import commMethods # importing a script ./pyolab/PyOLabCode/commMethods.py
Related
I would like to use the following sdk in my python project -> https://github.com/LBank-exchange/lbank-api-sdk-v2. It has sdk's for 3 languages (I just want the python one). I tried to install it using the command:
pip install git+https://github.com/LBank-exchange/lbank-api-sdk-v2.git#egg=lbank
which gave the error
does not appear to be a Python project: neither 'setup.py' nor 'pyproject.toml' found.
Looks like the developer didn't bother to package it properly. It it was me using it, I would fork it on GH, add the setup.py and use the fork. Maybe a good exercise for you?
Meanwhile, to just get it to work, in your project "root":
git clone https://github.com/LBank-exchange/lbank-api-sdk-v2.git
ln -s lbank-api-sdk-v2/python-sdk-api/LBank ./LBank
Then in your code just import LBank. This will leave the cloned repo untouched (so you can git pull to update it later) and just link the module directory to the root. Alternatively you can just include the api directory in sys.path for imports to work.
Think there is nothing to install, if you want to be able to "import" and use it like other packages you install through pip install you can just add the folder to your sys-path:
import sys
sys.path.append("path")
I'm attempting to install a featurestore package from a private GitHub repo via ssh with the following command:
pip3 install -U git+ssh://git#dsghe.<mydomain>/bshelton/package_test.git#master#egg=featurestore
The install is successful, per the image below:
But when trying to run from featurestore import *, I get a ModuleNotFoundError: No module named 'featurestore' error.
Using pip3 freeze, I see that the package is installed, but not with the <package>==<version> syntax I would expect, but it seems to be referencing the git commit instead as its "version":
I believe that the repo's directory set-up is appropriate for a Python package, per the screenshot below.
A noticeable difference between this package's install and the other packages I've installed is that it seems like only the ...dist-info folder is installed for my featurestore package, while every other installed package includes the actual package directory, in addition to the ...dist-info folder. Using ls ~/.local/lib/python3.6/site-packages:
This is my first time, trying to create a package like this, and I've been referencing the several sources below, but would appreciate some insight from the community as to what I'm missing. Thanks.
https://packaging.python.org/tutorials/packaging-projects/
pip install from git repo branch
The cause of my issue turned out to be a syntax error in my setup.cfg above the package_dir and packages lines, which are important if using a package layout with 'src'. Until I fixed the error, my package installed and imported fine in some contexts but not others
I was able to solve for this by moving my featurestore directory up one level, and getting rid of the src directory. Based on the top answer here, I may have been able to also solve for it by simply adding a __init__.py file directly in the src directory. But for my need, src was really an unnecessary level.
New package directory set-up:
Code ran in terminal:
!pip3 install -U git+ssh://git#dsghe.<mydomain>/bshelton/package_test.git#master#egg=featurestore
from featurestore.featurestore import *
I tried to install the keras_contrib package in a virtual machine which does not allow internet access. So I manually unzip the package, navigate to folder and using python setup.py install to install it. After that I can find the package using pip list, however when I import the package cannot be found. And I cannot find the package folder in the anaconda/lib/site-packages.
(link of the package: https://github.com/keras-team/keras-contrib)
These are the screenshots at the beginning and ending during installation.
Any suggestion? Thanks very much.
You should look at your $PYTHONPATH environment variables. If you are using Mac or Linux, write which python command on your terminal. Also, you can look at the link below for a setup that is similar to your problem
https://github.com/sparklingpandas/sparklingpandas/wiki/setup.py-Install-for-Anaconda-Python
I'm writing a plugin for an app, and found that packages I install with pip are apparently being ignored, so I'm trying to install them within my plugin's directory using
pip install --ignore-installed --install-option="--prefix=[plugins-folder]" [package-name]
This creates a folder structure lib/python2.7/site-packages/[dependencies] which is fine by me, except I can't figure out how to them import those dependencies. Even if I manage to import the main package, it will break because it can't find it's own dependencies which are also in that same directory structure.
I suggest that you should use virtual python environment. virtualenv for python2/python3 and python3 -m venv for python3.
You python environment seems orderless and you should isolate each environment for each python app.
I try the following code to see if the library sodium can be located
import ctypes
import ctypes.util
# Taken from line 33 https://github.com/bgaifullin/pysodium/blob/master/pysodium/__init__.py
o = ctypes.util.find_library('sodium')
print o
This always returns "none"
Please how do I add external libraries (dependencies) and reference them correctly in my python code.
EDIT:
I am trying to work with pysodium it has a dependency on libsodium
I have downloaded libsodium, but i'm new to python...
I'm actually using PTVS 2.1 to get up to speed running python in my familiar dev environment.
If I understood you correctly. What you want is to import a library.
Put the pysodium directory under the script you want to use and then simply do
import pysodium
It is as simple as that.
Usually, what you do is install the libraries on your system, or in a virtualenv, and import them to your python script. Cloning the repository will not generally help unless the libraries you want to import are in the same directory as the script you're importing from.
I, personally, would recommend using virtualenv and pip together hand in hand. Read up on virtualenv, it will come very handy.
Assuming you have both virtualenv and pip, all you need to do is the following
virtualenv venv
source venv/bin/activate
pip install pysodium
This should create a virtualenv container, activate it and install pysodium inside. Your script will only work when the virtualenv is activated. You can deactivate it using the command deactivate.