Unable to install notion-py module on Pythonista 3 using StaSh - python-3.x

I was trying to install notion-py on my phone to automate some tasks with iOS Shortcuts. I used Pythonista3, StaSh and typed 'pip install notion'. And it's not working as down below... is there any way that I could run notion-py module on my phone?
[~/Documents]$ pip install notion
Querying PyPI ...
Downloading package ...
Opening: https://files.pythonhosted.org/packages/eb/d5/2b184f608998cda08cc2862d7b4801f6e337490da2082b60aac04b287be4/notion-0.0.25-py3-none-any.whl
Save as: /private/var/mobile/Containers/Data/Application/C8ADF3B3-7229-4DBA-AF50-0585EB310D70/tmp//notion-0.0.25-py3-none-any.whl (39981 bytes)
[====================] 100.00% | 39.0KiB
Installing wheel: notion-0.0.25-py3-none-any.whl...
Package installed: notion
Dependency already bundled in distribution: requests
Installing dependency: commonmark (required by: notion)
Querying PyPI ...
Downloading package ...
Opening:
https://files.pythonhosted.org/packages/b1/92/dfd892312d822f36c55366118b95d914e5f16de11044a27cf10a7d71bbbf/commonmark-0.9.1-py2.py3-none-any.whl
Save as: /private/var/mobile/Containers/Data/Application/C8ADF3B3-7229-4DBA-AF50-0585EB310D70/tmp//commonmark-0.9.1-py2.py3-none-any.whl (51068 bytes)
[====================] 100.00% | 49.9KiB
Installing wheel: commonmark-0.9.1-py2.py3-none-any.whl...
Package installed: commonmark
Installing dependency: bs4 (required by: notion)
Querying PyPI ...
Downloading package ...
Opening:
https://files.pythonhosted.org/packages/10/ed/7e8b97591f6f456174139ec089c769f89a94a1a4025fe967691de971f314/bs4-0.0.1.tar.gz
Save as: /private/var/mobile/Containers/Data/Application/C8ADF3B3-7229-4DBA-AF50-0585EB310D70/tmp//bs4-0.0.1.tar.gz (1121 bytes)
[====================] 100.00% | 1.1KiB
Extracting archive file ...
Archive extracted.
Running setup file ...
PipError('failed to find packages or py_modules arguments in setup call',)
Failed to run setup.py
Fall back to directory guessing ...
Error: Cannot locate packages. Manual installation required.

Trying to install bs4 fails because BeautifulSoup is already included in Pythonista and not allowed to be overwritten.
If you ignore this error, there are other dependencies that will have trouble installing – I encountered at least ”slugify”. It is likely possible to install these by hand, i.e. finding the package repository and copying the files to site-packages yourself. wget in stash works well for this purpose.
Good luck!

Related

Python setuptools: How do I specify dependencies in a private PyPI repo, hosted on Nexus?

I'm unable to build a python wheel which has a dependency on a package in a private PyPI repository (hosted on Sonatype Nexus Repository Manager, vOSS 3.17.0-01).
I can search for and install the package if I use pip; my problem is trying to get setup.py to do the same. From looking into the output of various commands, I think the problem may be due to relative paths in the package links provided by the repository.
Searching for similar issues, most of them concern private git repositories. The most seemingly relevant related issue I could find is Equivalent for `--find-links` in `setup.py`. The body of that comment states that
In a setuptools context the dependency_links option accepts ... the URLs of web pages that contain direct download links
However, the linked page is offered in support of that quote no longer contains that text (replaced by a newer version?)
So that may be the problem - and the way I'm trying to do things is not supported. If that's the case, can someone suggest a way that works?
Alternatively, this could be a bug in setuptools, or a misconfiguration problem with our Nexus - and if anyone could confirm or refute those theories - and again, suggest an approach that works - I'd appreciate it.
Here's my setup and the output of various commands, showing what works and what doesn't:
Set up the environment:
mkdir depends-fail
cd depends-fail
python3 -m venv venv
source activate venv/bin/activate
pip install --upgrade pip
pip install wheel # So we can use bdist_wheel build option.
Confirm our current pip version:
(venv) $ pip --version
pip 21.0.1 from /tmp/depends-fail/venv/lib/python3.6/site-packages/pip (python 3.6)
Confirm setuptools version:
(venv) $ python -c "import setuptools as s; print(s.version.__version__)"
39.0.1
In the depends-fail directory, create this minimal setup.py file, which will demonstrate the problem:
from setuptools import setup
setup(
name='failed-dependencies',
install_requires=['data-feed-ping>=0.5'],
dependency_links=[
'http://nexus.example.local/nexus/repository/pypi-playground-public/simple/data-feed-ping',
]
)
Confirm that our dependency is available in our private repository:
(venv) $ pip search --trusted-host nexus.example.local \
> -i http://nexus.example.local/nexus/repository/pypi-playground-public/pypi \
> data-feed-ping
The response confirms the package is locally available:
⋮
Starting new HTTP connection (1): nexus.example.local:80
http://nexus.example.local:80 "POST /nexus/repository/pypi-playground-public/pypi HTTP/1.1" 200 239
data-feed-ping (0.5) - Determine response times of data feeds.
Here's what happens when we try to build and test our minimal package (it's the test option which triggers the dependency downloads):
(venv) $ python setup.py bdist_wheel test
The package builds without problem - but the dependencies can't be found:
running bdist_wheel
running build
⋮
removing build/bdist.linux-x86_64/wheel
running test
Searching for data-feed-ping>=0.5
(1) Reading http://nexus.example.local/nexus/repository/pypi-playground-public/simple/data-feed-ping
(2) Downloading http://nexus.example.local/nexus/repository/packages/data-feed-ping/0.5/data_feed_ping-0.5-py3-none-any.whl#md5=e7a9ee0be6cc77165d02e7022c04b336
error: Can't download http://nexus.example.local/nexus/repository/packages/data-feed-ping/0.5/data_feed_ping-0.5-py3-none-any.whl#md5=e7a9ee0be6cc77165d02e7022c04b336: \
404 Repository not found
The download link and version hash in (2) come from the contents of the index URL read at (1) - so let's see what that file looks like:
(venv) $ curl http://nexus.example.local/nexus/repository/pypi-playground-public/simple/data-feed-ping
<html lang="en">
<head><title>Links for data-feed-ping</title><meta name="api-version" value="2"/></head>
<body><h1>Links for data-feed-ping</h1>
⋮ <!-- links to previous versions -->
data_feed_ping-0.5-py3-none-any.whl<br/>
</body>
</html>
The index URL does provide a link to the required version of the data-feed-ping package, and the setup script is correctly picking up the md5 digest from that link (see (2) in the script output). However, the setup script then tries to download the file from an invalid URL.
To me it looks as if the problem is the relative path provided by the index link. If we start with the index URL (1):
http://nexus.example.local/nexus/repository/pypi-playground-public/simple/data-feed-ping
and add the relative path from the download:
../../packages/data-feed-ping/0.5/data_feed_ping-0.5-py3-none-any.whl#md5=e7a9ee0be6cc77165d02e7022c04b336
I get the following absolute path:
http://nexus.example.local/nexus/repository/pypi-playground-public/packages/data-feed-ping/0.5/data_feed_ping-0.5-py3-none-any.whl#md5=e7a9ee0be6cc77165d02e7022c04b336
I've confirmed that that absolute path leads to the package I want:
(venv) $ wget http://nexus.example.local/nexus/repository/pypi-playground-public/packages/data-feed-ping/0.5/data_feed_ping-0.5-py3-none-any.whl#md5=e7a9ee0be6cc77165d02e7022c04b336
--2021-04-01 16:44:18-- http://nexus.example.local/nexus/repository/pypi-playground-public/packages/data-feed-ping/0.5/data_feed_ping-0.5-py3-none-any.whl
Resolving nexus.example.local (nexus.example.local)... 192.168.24.136
Connecting to nexus.example.local (nexus.example.local)|192.168.24.136|:80... connected.
HTTP request sent, awaiting response... 200 OK
Length: 19066 (19K) [application/zip]
Saving to: ‘data_feed_ping-0.5-py3-none-any.whl’
data_feed_ping-0.5-py3-none-any 100%[==========================================>] 18.62K --.-KB/s in 0s
2021-04-01 16:44:18 (76.3 MB/s) - ‘data_feed_ping-0.5-py3-none-any.whl’ saved [19066/19066]
I also have no problem if I try and download the package directly, with pip, specifying the same index URL that the setup script uses:
(venv) $ pip install --trusted-host nexus.example.local \
> --index-url http://nexus.example.local/nexus/repository/pypi-playground-public/simple \
> data-feed-ping
Looking in indexes: http://nexus.example.local/nexus/repository/pypi-playground-public/simple
Collecting data-feed-ping
Downloading http://nexus.example.local/nexus/repository/pypi-playground-public/packages/data-feed-ping/0.5/data_feed_ping-0.5-py3-none-any.whl (19 kB)
Requirement already satisfied: requests in ./venv/lib/python3.6/site-packages (from data-feed-ping) (2.25.1)
⋮
Installing collected packages: data-feed-ping
Successfully installed data-feed-ping-0.5
You should only use pip (or any other installer) to install Python projects. Installing by calling python setup.py install for example is an outdated practice (that often does not work). So in consequence, you probably should remove the dependency_links parameter of your setup.py, and instruct your users to install with the correct pip flags exactly as you have shown at the end of your question:
python -m pip install --trusted-host nexus.example.local \
> --index-url http://nexus.example.local/nexus/repository/pypi-playground-public/simple \
> data-feed-ping
In the same way python setup.py test: is outdated/deprecated as well, and you might be well-advised to move on to a more modern test runner (pytest is the one that comes to mind, but there are probably others, maybe nose).
References:
https://blog.ganssle.io/articles/2021/10/setup-py-deprecated.html
https://github.com/pypa/pip/issues/4187#issuecomment-415067034

How to install torch==0.3.1 in python=3.6

I am trying to install deepmatcher package in python 3.6. To let this package to run in python you need have a torch==0.3.1 version. So I am trying to install torch==0.3.1 by running :
pip install torch==0.3.1
Error during installation:
Collecting torch==0.3.1
ERROR: Could not find a version that satisfies the requirement torch==0.3.1 (from versions: 0.1.2, 0.1.2.post1)
ERROR: No matching distribution found for torch==0.3.1
I even tried installing it using "peterjc123" package but still unable to uninstall it.
torch 0.3.1 is not listed official anymore. To install torch 0.3.1 one can either build it by source or using a whl file for the specific version.
Using a whl file
whl files can be found here provided by pytorch
The downloaded file can then be installed with pip install [path to downloaded file]
Build by source
To build torch by source one can checkout the desired version via git
git checkout v[version number]
For torch==0.3.1 this would be git checkout v0.3.1
After this follow the install instructions provided by README.md
More information can be found at: https://pytorch.org/get-started/previous-versions/
check if you have right python installed for you os architecture or
create a virtual env using conda and then try installing its better this way

Error installing required modules from setuptools (matplolib)

I am developing a python library that I wish to distribute afterwards. In order to do this I am configuring setuptools. Currently I am testing all this in a fresh install of Ubuntu 18.0.4.2 after doing an update & upgrade.
The problem is that my setup.py looks like this (I defined the oldest available package):
setup(
...
install_requires=[
'setuptools>=40.0.0',
'matplotlib>=1.0.1',
'numpy>=1.3.0',
'scipy>=0.8.0',
],
...
)
and when I install my package from test.pypi I get this error with matplotlib:
Collecting LIB_TEST_NEW
Using cached https://test-files.pythonhosted.org/packages/e6/6a/d3f7569c437b70e4c048e8597977c3d42e9baa1151c0245f210cb6e529f1/LIB_TEST_NEW-0.1.2-py3-none-any.whl
Collecting matplotlib>=1.0.1 (from LIB_TEST_NEW)
Could not find a version that satisfies the requirement matplotlib>=1.0.1 (from LIB_TEST_NEW) (from versions: )
No matching distribution found for matplotlib>=1.0.1 (from LIB_TEST_NEW)
I have tried both with and without specifying the version of the modules and also defining the modules in a separate requirements.txt.
Any help would be appreciated :)
SOLUTION:
After some digging I found a solution.
"If you want to allow pip to also pull other packages from PyPI you can specify --extra-index-url to point to PyPI. This is useful when the package you’re testing has dependencies:"
Then using:
pip install --index-url https://test.pypi.org/simple/ --extra-index-url https://pypi.org/simple your-package
Solved my error. Hope it helps someone.

setuptools, use package on local system instead of getting it from PyPI

There is an open-source python package that I want to work on (toga-android). To test the code I write, I have to be able to build my own project that has said open-source package as a dependency. My project has to be built with setuptools, so I need setuptools to fulfill the dependency using my version of the package, and not get the package from PyPI.
The problem is that setuptools always gets the package from PyPI.
Whenever I build with setuptools I see:
Collecting toga-android==0.3.0.dev8
Downloading https://files.pythonhosted.org/packages/92/fe/348a39e2e0bbcac2d3ed511dd2b62943b488e7dcb8097c437416caf1c179/toga_android-0.3.0.dev8-py3-none-any.whl
or
Collecting toga-android==0.3.0.dev8
Using cached https://files.pythonhosted.org/packages/92/fe/348a39e2e0bbcac2d3ed511dd2b62943b488e7dcb8097c437416caf1c179/toga_android-0.3.0.dev8-py3-none-any.whl
Clearly it is getting the package from PyPI or using a cached version from it.
I have installed my version using pip install -e . , and that has no effect. I have also tried including the package's source in my project's directory with setup.py. Setuptools apparently includes this code because syntax errors there make the build fail, but it doesn't recognize that it can satisfy the dependency. It still gets the package from PyPI and any modules imported from the package are the PyPI versions.
How can I use of custom version of a package that is also in PyPI as a setuptools dependency?
Steps to reproduce:
pip install briefcase (using or not using virtualenv does not matter)
git clone https://github.com/pybee/toga.git
cd ~/toga/src/core; sudo pip install -e .
cd ~/toga/src/android/; sudo pip install -e .
cd ~/toga/examples/tutorial0
python setup.py android
The output will show that an older version of toga-android is downloaded even though it was already installed with pip.

Conda keeps trying to install all optional dependencies?

When installing Theano anaconda automatically tries to install pygpu despite this being an optional dependency. I have deleted the .theanorc file from my windows user directory.
Also when running my application Theano tries to load from the GPU. It's like it remembers somehow?
conda install theano
Fetching package metadata .............
Solving package specifications: .
Package plan for installation in environment
C:\Users\zebco\Miniconda3\envs\py35:
The following NEW packages will be INSTALLED:
libgpuarray: 0.6.9-vc14_0
pygpu: 0.6.9-py36_0
theano: 0.9.0-py36_0
Proceed ([y]/n)?
As you can see I've only specified to install theano yet conda wants to install everything including optional dependancies.
Your assumption that pygpu is optional is dependent on the package manager you are using.
Regular Python (pip)
If you are using a direct Python install (obtained using brew or Python site) then you would be using pip to install theano. This basically comes from
https://pypi.python.org/pypi/Theano/1.0.0
If you download the file and unzip it. Open setup.py, you will see below lines
install_requires=['numpy>=1.9.1', 'scipy>=0.14', 'six>=1.9.0'],
So they are set as the dependencies for this package. Which means when you install theano you will also get numpy, scipy and six.
Anaconda Python (conda)
Now coming to Anaconda python. Anaconda doesn't use a package format that PyPI or pip uses. It uses its own format. In case of Anaconda you should be using conda to install the packages you need and not pip.
Conda has channels which is nothing but a repository which has some packages available. You can install a package from any channel using below
conda install -c <channel-name> <package-name>
The default channel is conda-forge. If you look at the theano package over there
https://anaconda.org/conda-forge/theano/files
And download and extract it. There will be a info/recipe/meta.yml file. You will notice below content in the same
requirements:
build:
- ca-certificates 2017.7.27.1 0
- certifi 2017.7.27.1 py36_0
- ncurses 5.9 10
- openssl 1.0.2l 0
- python 3.6.2 0
- readline 6.2 0
- setuptools 36.3.0 py36_0
- sqlite 3.13.0 1
- tk 8.5.19 2
- xz 5.2.3 0
- zlib 1.2.11 0
run:
- python
- setuptools
- six >=1.9.0
- numpy >=1.9.1
- scipy >=0.14
- pygpu >=0.6.5,<0.7
Which specifies that if you want to run this package then pygpu is also on of its dependencies. So conda downloads pygpu as a dependency which you though was optional (which is probably true if you were using regular python and pip)
Update:
Usually, 'Optional Dependency' is an oxymoron. Something optional is not a dependency, a dependency is a software package another piece of software depends on to function for features.
One may get by without a dependency if the dependency does not interact with the package except for one atomized feature which is not being used. As a beginner I would suggest you not take this path.
I am not super familiar with Theano, but Theano can use the system's GPU to speed up its computations, and it seems to me pygpu and gpulibarray are what enable this functionality. Which means it is not optional.
I believe pygpu is 'optional' if you do not wish to use the GPU for speeding up computation (only done if the GPU is powerful enough to be useful for this).
The --no-deps command above allows you to install a package without its dependencies but that is rarely wise, unless one really knows what they are doing. As a beginner I would not recommend you go down this path yet. Conda was designed specifically to ensure scientific packages are easily managed with all necessary stuff installed without any fuss or muss. pip is a general python package manager, but is not built specifically for scientific packages.
If you wish to install theano without installing its dependencies, then you have one of three options:
use conda install theano --no-deps.
Install it using pip instead of conda, using pip install theano. This will install theano, numpy, scipy and six but not pygpu and libgpuarray.
Create a custom conda build file for Theano. Documentation is at:
https://conda.io/docs/user-guide/tasks/build-packages/index.html
Original Answer:
You probably know this already but, use this command instead:
conda install theano --no-deps
This does not install dependencies of the package. If you already have the essential dependencies installed, as it would seem, this should work out for you.
libgpuarray is a dependency of pygpu. With this command switch neither will be installed.
Can you share the .yaml file that you edited?

Resources