I am creating a package in python with setuptools. I am using a MANIFEST.in file to include a dependency that my package utilizes. I specify the contents of the MANIFEST.in as below:
recursive-include package/dependency_directory *
The package builds and installs without error. However, when I call the package from one of the entry points I see that the script fails because it cannot find the correct filepath to the contents of MANIFEST.in.
The path that the package is looking at is this:
/Users/Xerez/Library/Caches/Python-Eggs/qasar-0.1-py2.7.egg-tmp/qasar/fastqc/fastqc
The rest of the package is installed at:
/Users/Xerez/anaconda2/lib/python2.7/site-packages/qasar-0.1-py2.7.egg
However, inside my IDE when I ask where the package is using the code below:
DATA_PATH = pkg_resources.resource_filename('qasar', 'fastqc/fastqc')
I get the following filepath:
/Users/Xerez/anaconda/lib/python2.7/site-packages/qasar-0.1-py2.7.egg/qasar/fastqc/fastqc
When I run the script from within the IDE using this path everything works fine. I recognize that MANIFEST.in is installing in a distinct location from the rest of the package and that my IDE is calling yet another distinct form of python. How may I force the installation to put everything in the same version_of_anaconda/location?
I attach a link to a bitbucket repository which has a stripped down version of the package that may assist in answering this question.The link is also written below:
https://bitbucket.org/arp2012/stackoverflow/src/master/
I apologize if the answer to this question is trivial, but I haven't been able to find a solution to this problem for a bit and decided to ask for help. Thank you in advance!
Ultimately, I was able to solve the multiple python path issue by installing the package inside of a docker container that only had one version of python and anaconda installed. This solution, however, is neither ideal nor elegant.
Related
I'm trying to use the code from this repository. The problem is that it isn't a package (I think?) because it can't be found on PyPI and there's no setup.py file (so I can't use pip install git+<repo link>). How would I then be able to use this code in my project?
I've already read this question, which also involved not having a setup.py file, but the answer seems unsatisfactory to me. I'm under the impression that it wouldn't allow my project to be run on someone else's pc without them also manually installing the code from the aforementioned repo.
I've also thought about just downloading the code and adding a setup.py myself, but I think that would produce the same problem.
I'm clearly a little unclear on this subject and I can't find any explanation/solution anywhere else.
That repository doesn't seem to be properly packaged for library use at all.
I'd recommend forking it, making the changes you need to make it usable (moving the files into a package, adding a setup.py) and then using that as a git+https:// style requirement.
I need to make some changes to the way the OSMnx package gets data from the Overpass API.
To do that, I've forked the repo and cloned that fork into a local directory.
I've made a simple change, adding a print functions to start.
I'm trying to figure out the steps for installing and importing the modified version of the package. I've looked at this question
I'm concerned about a namespace conflict, should I change the name of the folder or the name value in the setup.pyfile. I don't want to write over the working version of the package
What file should I point to when installing? setup.py, core.py, _init_.py?
I haven't found any tutorials on how to modify an existing package safely, just stuff on how to make a package from scratch.
import will search the installed packages list first, then it will check the directory it was called from for files that match the package it's looking for.
So either using pip or conda remove the original version of the package being imported.
Then, be sure that the modified version of the package that you want to import is in a sibdirectory of your project directory, and run import package as xx and it should load the modified package files.
If it doesn't, it's likely that the package wasn't removed from the right environment.
In short, my question is, how do I install the latest version of scikit-image into my usr/lib/python3/dist-packages so I can actually use it? I think there is a problem with my understanding of how third-party modules are installed. As a newb, I don’t know how to rectify that, hence this post.
I need help to understand how to install packages in python3 up until now I have used pip/pip3/apt-get/synaptic etc and it has worked fine for many packages. However, I have hit several barriers (Skimage, opencv, plantcv in python3). I must emphasise, the problem I am having is using these packages in python3, not 2.7.
For example, I want to use the latest version of scikit-image (0.14) with python3. (http://scikit-image.org/) I have tried using the installation instructions and have not yet successfully managed to install it. I have navigated to my usr/lib/python3/dist-packages and copied scikit-image into this directory (I have all the dependencies installed in here already).
Image of my folder for dist-packages as proof
As you can see, the folder containing skimage is in the directory I want to be installed in, how do I actually install it? Do I have to extract skimage out of the folder into the directory and then run the install command? If I navigate to usr/lib/python3/dist-packages/scikit-image and then run pip install -e . I get an error, stating that I need numpy. If I write a python script using python3 I can clearly see I have it installed (and I have been using it for a long time). So, there must be a problem in how I have this package in my file system. I think a janky workaround would be to copy all the modules into my working directory and Import them that way as if they were modules I have made myself, but this obviously negates the whole point of installing packages.
This has also happened with another package called plantcv. Where I went into the directory usr/lib/python3/dist-packages then cloned the source from git hub and installed as per instructions. When I import plantcv in my python3 script. It Imports fine. But, there is nothing in it, as python cannot see the modules which are inside this folder at usr/lib/python3/dist-packages/plantcv/plantcv.
There is clearly some comprehension here that I am missing, as I have a similar problem for two packages now. Please, Internet. Help me understand what I am missing!
You simply need to copy the folder in /usr/lib/python3/dist-packages/package-name
However, there are certain things that are specific to python packages. The folder named package name should be a valid package. A good indicator of that is it will contain a file "__init__.py". It is very likely that every sub-directory inside this package directory will contain a "__init__.py" file. It depends on whether there are modules inside these sub-directories.
In your code simply import the package like the following.
import package-name
where package-name can be skimage
I am trying to find a way to include a library in a Ubuntu/Python/PyGtk application even though It is not included in the stock python enviornment and I can't add it as a dependency in my setup.py file. The library is called pygal and does have a PIP package (No available .deb or ppa) but I was looking for a way to include it in my application. I would think I could just include the source .py files to the library but I am unsure of how to go about including it in my code. Pygal also requires the lxml python library. I can install it via pip on my machine and it works fine but didn't know if there was anyway to automate or include this in my .deb package's setup.py file. Any help or advice would be greatly appreciated.
I think this should work though I'm not sure.
You put the folder with the name pygal from the pygal egg in your application directory. You can take it from your python installation - it should have this path:
/usr/local/lib/python2.7/dist-packages/pygal-0.13.0-py2.7.egg/pygal
or if you use python 3.1
/usr/local/lib/python3.1/dist-packages/pygal-0.13.0-py3.1.egg/pygal
or download it from pipy.
You can use it like any python library:
from pygal import *
I've actually figured out how to package this as a *deb file that I can include in my future PPA (or possibly submit to the community) that will (hopefully) cleanly install the python package on the system. I found a great write up in the Debian wiki that actually doesn't seem cryptic to a newbie like myself, oddly enough.
http://wiki.debian.org/Python/Packaging#Example_1:_Python_extension
I downloaded an open source project http://gmapcatcher.googlecode.com/files/GMapCatcher-0.7.2.0.tar.gz and I am trying to modify a few things in the code but don't know how to test the code!
I tried to make an installer for the project but nothing worked till now maybe I didn't follow the right steps or I am missing somthing.
my question is how can I modify the code and test it ? and how can I make an installer for this project (I know there is an installer already in google but I want to make it myself).
Looks like the package has a setup.py for the use with distutils. The setup.py works kind of like Makefile for python. The way you use it is (in the directory where setup.py is located:
$ python setup.py command
Where "command" is... well... a command. Type
$ python setup.py --help
for more information. The two basic commands are build and install. install installs, as the name suggests, the package to your system. It is not probably going to do anything like create shortcuts on your desktop or anything like that. It simply installs the Python package into your Python installation. Judging by the contents of setup.py, it seems they're somehow using py2exe (google it; being a newbie I can only include one hyperlink in my answer) to prepare the Windows installer.
To simply run the software, however, it seems all you need to do is to unpack it and do
$ python maps.py
in the package's root directory - provided you have all the necessary dependencies already installed, of course.