Module Not Found Error For Custom Pypi Package - python

I am trying to upload my package to pypi and use it. Using Twine i upload it to pypi but when i try to use this package I get Module not found error.
My Error :
My Folder structure for the package is :
The error points to the modelpg/__init__.py , here's my modelpg/__init__.py file.
Is it due to my package name is same as .py file.
EDIT 1 :
My Transformer/__init__.py file

All of the imports in modelpg/__init__.py would need to either be relative:
from .Transformer.transformer import Transformer
or absolute, with the modelpg package name:
from modelpg.Transformer.transformer import Transformer
This has nothing to do with PyPI, by the way – the same applies even if the package wasn't installed from there.

Related

Module dependencies

I am using ray library of python but I got an error even if I have the mentioned file.
The error is the following:
FileNotFoundError: Could not find module 'C:\Users\boezi\PycharmProjects\AWSDeepRacerChallenge\env\lib\site-packages\ray_raylet.pyd' (or one of its dependencies). Try using the full path with constructor syntax.
pip did not recognize the library, therefore I downloaded the wheel archive, I extracted it and I put the content in the site-packages folder of my virtual environment.
The package is recognized and I can use automatic filliing with my IDE but I have the aforementioned problem.

Issue importing Google Neuroglancer Package

I am using Google's Neuroglancer which I downloaded from GitHub and trying to run an example script provided by them. However, one of the lines is import neuroglancer, and since I cloned the whole repo there is a neuroglancer folder with all of the required files, but I am getting the following error:
ImportError: No module named 'neuroglancer'
Is there any way I could fix this? I don't see the issue since neuroglancer is in the same file path as the python script.
In case you are running the example in the neuroglancer project try following their guide.
Otherwise you might want to try and installing the Neuroglancer package using something like pip and a virtual environment to be able to import the package into the project.

AWS Lambda -- Unable to import srsly.ujson.ujson for SpaCy

I am trying to add SpaCy as a dependency to my Python Lambda. I am doing this by installing SpaCy as a standalone dependency inside a directory named dependencies using pip3 install spacy --no-deps -t . This is because I can't load the entire Spacy dependency inside the \tmp directory of my Lambda.
I am able to successfully upload the folder to s3 and download it during the Lambda invocation. When I try to import spacy, I get this error: [ERROR] Runtime.ImportModuleError: Unable to import module : No module named 'srsly.ujson.ujson'.
I manually installed srsly inside dependencies\ and I have all the files that are listed as per this link. This was referenced by this link. One of the responses says, "it seems like Python can't load it, because it's not compiled?". How would I compile a dependency which has a .c file in it?
One other question which I found on SO is this question, but I have already manually installed srsly. How to I import the module? Thanks.
I manually check in my code for the presence of ujson before importing spacy like this:
if os.path.exists('/tmp/dependencies/srsly/ujson/ujson.c'):
print('ujson exists')
and the print statement gets printed.
For me pip uninstalling and installing srsly again worked fine.. sometimes its just the compatibility issue with your python version so make sure correct python/srsly versions are present
Well it is a bit strange, but my solution for this problem was to create an aditional "ujson" folder in the srsly folder and then move all the ujson generated code to the folder "ujson" previously created

Unable to read TXT files from outside a PyPi package

I am having a lot of issues when uploading a PyPi package, because I have a package that reads information from a TXT file in another directory. This is my project structure:
I can read the files if I do it using my own package from the PyCharm project, but the problem is when I upload it to PyPi and I import is as a pip package.
I read the file in local this way:
tickers = pd.read_csv('../data/tickers.csv')
But that does not work when I install the package using pip.
I have been trying to configure setup.py, but with no succeed, because when I install the package uploaded to PyPi using pip, I get an error like this:
FileNotFoundError: [Errno 2] No such file or directory:
'data/user-agent-list.txt'
This is what I have in my setup.py related to those external files contained in the data/ directory:
I also have a MANIFEST.in to include the data files:
I hope the information I provided is enough for you to let me know how can I fix this... To give you extra information, I am following this tutorial to upload my package to PyPi, but the error has nothing to do with it.
Thank you!
I am wondering if the issue is not related to the path you are using here:
pd.read_csv('../data/tickers.csv')
It refers to the path that is relative to the base execution path of the script that is using your module. Try using a non-relative path. You may also want to use the install path as suggested in this question.

Where to get sphinxcontrib.autohttp.flask?

I am looking to generate automatic documentation for the REST API of a Flask project. I can't locate the sphinx extension sphinxcontrib.autohttp.flask anywhere and it does not seem to come bundled with sphinx. When I run sphinx I get :
Extension error:
Could not import extension sphinxcontrib.autohttp.flask (exception: No module named sphinxcontrib.autohttp.flask)
Can somebody give me a pointer to where to find it?
The sphinxcontrib.autohttp.flask module lives in the sphinxcontrib.httpdomain contrib extension which you can find here https://bitbucket.org/birkenfeld/sphinx-contrib or you can install it directly using pip like this:
pip install sphinxcontrib-httpdomain

Categories