Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ModuleNotFoundError: No module named 'ankisyncd' #128

Open
Nriver opened this issue Feb 28, 2022 · 12 comments
Open

ModuleNotFoundError: No module named 'ankisyncd' #128

Nriver opened this issue Feb 28, 2022 · 12 comments

Comments

@Nriver
Copy link

Nriver commented Feb 28, 2022

This commit e47ed57 breaks the cli tool. Executing ankisyncd_cli/ankisyncctl.py adduser <username> will throw ModuleNotFoundError: No module named 'ankisyncd'

@isudfv
Copy link

isudfv commented Mar 4, 2022

manual should update too

@VikashKothary
Copy link
Member

@Nriver Apologies for the issue. I've pushed a quick fix for this issue.
Please let me know if it resolves your issue.

@isudfv I'm in the process of tidying up the code, and will update the documentation as part of the process. But feel free to reach out if there is any questions in the mean time.

Many thanks for raising this to my attention.

@logexp1
Copy link

logexp1 commented Mar 11, 2022

has this issue resolved? I get same errors...

@VikashKothary
Copy link
Member

Hi @hackmalife, I have re-opened this issue. However, I will need your help to be able to reproduce this issue because it works for me.

Can you confirm you're on the latest commit on the develop branch and then comment how you're getting this error?

@VikashKothary VikashKothary reopened this Mar 12, 2022
@logexp1
Copy link

logexp1 commented Mar 13, 2022

Thanks, @VikashKothary. I installed via AUR, so I believe it's the most recent commit. After I pip install requirements.txt, the rest of it and error messages are exactly same as the original comment, #128 (comment)

@logexp1
Copy link

logexp1 commented Mar 15, 2022

anyways, I got around this issues by inserting parents path of ankisyncd_cli to system path for now

@uzqw
Copy link

uzqw commented Apr 4, 2022

I have no idea what's up, just got the same error as the issue name.
Here's my solution.

$ /anki-sync-server/src/ankisyncd_cli# mv ankisyncctl.py migrate_user_tables.py ../
$ /anki-sync-server/src/ankisyncd_cli# cd ..
$ /anki-sync-server/src# python -m ankisyncd

then work fine on both 2.1.46(pc-linux) and 2.15.6(android)

another error ( the error probably cause by something in 2.1.49 client )

  File "/home/w/anki-sync-server/src/ankisyncd/sync_app.py", line 210, in uploadChanges
    processed_count = self._adopt_media_changes_from_zip(z)
  File "/home/w/anki-sync-server/src/ankisyncd/sync_app.py", line 282, in _adopt_media_changes_from_zip
    assert self.col.media.lastUsn() == oldUsn + processed_count  # TODO: move to some unit test
AssertionError
[2022-04-05 05:41:45,310]:INFO:ankisyncd.http:127.0.0.1 "POST /msync/uploadChanges HTTP/1.0" 500 59

solved by comment the "sync_app.py: line 282 && line 274"

after this one another error occurred, then I gave up and turned to the 2.1.46 client

  File "/home/wwo/anki-sync-server/src/ankisyncd/sync_app.py", line 125, in start
    self.apply_graves(graves,self.maxUsn)
  File "/home/wwo/anki-sync-server/src/ankisyncd/sync.py", line 230, in apply_graves
    self.col.decks.remove(graves['decks'])
AttributeError: 'DeckManager' object has no attribute 'remove'

@posLop
Copy link

posLop commented May 8, 2022

i experienced this too and just moved the ./ankisyncd_cli/ankisyncctl.py into ./ and reran it

@ghoski
Copy link

ghoski commented May 10, 2022

@VikashKothary Minimal reproducible example as a Docker image:

FROM debian:latest
RUN apt-get update && apt-get upgrade -y
RUN apt-get install -y git python3-pip

RUN git clone https://github.com/ankicommunity/anki-sync-server
WORKDIR /anki-sync-server/src

RUN pip install -r requirements.txt
RUN cp ankisyncd.conf ankisyncd/
RUN mv ankisyncd_cli/ankisyncctl.py . # breaks without this
RUN echo pwd | python3 ankisyncctl.py adduser user # username user, password pwd
CMD python3 -m ankisyncd

Build and run with docker build -t anki-debug . && docker run --publish 27701:27701 anki-debug.

Removing the RUN mv ankisyncd_cli/ankisyncctl.py . and replacing ankisyncctl.py with ankisyncd_cli/ankisyncctl.py gives ModuleNotFoundError: No module named 'ankisyncd' on the adduser step.

Edit: The previous error was due to an oversight on my part. The error message now reflects this issue's topic.

@VikashKothary
Copy link
Member

VikashKothary commented May 16, 2022

@ghoski Much appreciated. I'll try and have a look this weekend if I have the time.

But my first guess would be that you're not installing the package. But when you move it one-level higher, Python treats the package name as a relative import.

Poetry installs the package out-of-the-box (poetry install --no-root from the root folder, not src) but I think we'll need to add a setup.py those who wish to not use it.

Once we've done that, you should be able to replace the RUN mv ankisyncd_cli/ankisyncctl.py . with RUN pip install -e .. but your workaround is as good as mine tbh.

This should be a short-term bug anyway because the plan is to deploy the CLI to PyPI which means you can use it without cloning the whole repository in the future. Which should hopefully make the maintenance of the sync server a lot simpler.

Apologies again for the inconvenience.

@pgroce
Copy link

pgroce commented Jun 12, 2022

Hi, I was wondering if there's been any progress on this? I didn't see it in PyPI, but I may have missed it.

FWIW, pip install -e . didn't work for me, I got the following error:

ERROR: Project file:///root/src/anki-sync-server has a 'pyproject.toml' and its build backend 
is missing the 'build_editable' hook. Since it does not have a 'setup.py' nor a 'setup.cfg', 
it cannot be installed in editable mode. Consider using a build backend that supports PEP 660.

(Line breaks added for legibility.)

Running pip install . was succesful, but I haven't tested it yet, as I'm still working on getting the server running.

As a user, I would love to see a setup.py or (better yet) a PyPI upload, but installing via Poetry is easy enough. It does install a number of dependencies I don't need as a user, but it's not a primary concern.

It would be nice, if you want to leave the existing workaround in place, to document it more fully in the readme. The main problem right now, from my POV, isn't that the installation is difficult, but that it's not properly documented. (I'm very glad this issue exists, I would probably still be fumbling around deciding on a way forward if it didn't.)

Thanks very much for your work on this project, I hope you find this feedback helpful.

@VikashKothary
Copy link
Member

Thank you for your feedback and kind words, it's always appreciated.

I have implemented some actions based on the comments above:

  • I've added a setup.py to allow users to use pip install -e src
  • I updated the Poetry pyproject.toml to ensure the the ankisyncd_cli package is installed.
  • I've added a known issues section to the README.
  • I've created a new release and uploaded it to PyPI which can be installed using pip install anki-sync-server then you can use the CLI using python -m ankisyncd_cli
  • I've updated the README

Tbh, I was a bit of a rush job so it could probably needs to be improved over time, but hopefully it should fix this issue.

I'd also ask that if anyone here finds any inconsistencies with the documentation, please raise a PR to improve it. Even small changes can make a huge difference to new and existing users alike. I do my best to keep it up to date but I do often miss things.

Please review my changes and let me know if we can close this issue.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

No branches or pull requests

8 participants