ankicommunity / ankicommunity-sync-server

A personal Anki sync server (so you can sync against your own server rather than AnkiWeb)
GNU Affero General Public License v3.0
883 stars 81 forks source link

cannot found Anki module #75

Open jabobian opened 3 years ago

jabobian commented 3 years ago

Following the procedures, I got:

(ankiweb) D:\Soft\Language\Anki\anki-sync-server\src>python -m ankisyncd Traceback (most recent call last): File "d:\Miniconda3\envs\ankiweb\lib\runpy.py", line 193, in _run_module_as_main "main", mod_spec) File "d:\Miniconda3\envs\ankiweb\lib\runpy.py", line 85, in _run_code exec(code, run_globals) File "D:\Soft\Language\Anki\anki-sync-server\src\ankisyncd__main__.py", line 8, in import ankisyncd.sync_app File "D:\Soft\Language\Anki\anki-sync-server\src\ankisyncd\sync_app.py", line 37, in import anki.db ModuleNotFoundError: No module named 'anki'

So I googled and found https://github.com/dsnopek/anki-sync-server/issues/40 There is a anki-bundled link in https://github.com/dsnopek/anki-sync-server Copying the downloaded anki folder to D:\Miniconda3\envs\ankiweb\Lib\site-packages and rerun shows Exception: Anki should be run with Python 2

So I download https://github.com/ankicommunity/anki-core/tree/master/anki and copy to D:\Miniconda3\envs\ankiweb\Lib\site-packages Now the error is as follows: (ankiweb) D:\Soft\Language\Anki\anki-sync-server\src>python -m ankisyncd Traceback (most recent call last): File "d:\Miniconda3\envs\ankiweb\lib\runpy.py", line 193, in _run_module_as_main "main", mod_spec) File "d:\Miniconda3\envs\ankiweb\lib\runpy.py", line 85, in _run_code exec(code, run_globals) File "D:\Soft\Language\Anki\anki-sync-server\src\ankisyncd__main__.py", line 8, in import ankisyncd.sync_app File "D:\Soft\Language\Anki\anki-sync-server\src\ankisyncd\sync_app.py", line 41, in from ankisyncd.full_sync import get_full_sync_manager File "D:\Soft\Language\Anki\anki-sync-server\src\ankisyncd\full_sync.py", line 11, in from anki.collection import Collection ImportError: cannot import name 'Collection' from 'anki.collection' (d:\Miniconda3\envs\ankiweb\lib\site-packages\anki\collection.py)

Please help, and Thanks!

VikashKothary commented 3 years ago

Hi @jabobian,

Thank you for raising this issue.

So the first thing I want to check is that you are using the latest version of the server i.e. the develop branch? This version of the anki-sync-server will install anki directly from PyPI.

I would also like to confirm your Python version. The latest version of anki requires a minimum Python version of 3.8.

Finally, can you provide your operating system? It looks like you're using Anaconda (Miniconda) on Windows. What command are you using to install the requirements?

Once you provide the following information, we can look into this further.

jabobian commented 3 years ago

Hi, @VikashKothary My Python version 3.7. I will try to install Python 3.8. OS is Win 10, with Miniconda. The commands used are

  1. conda clone -n ankiweb --clone kivy37 // kivy37 is my earlier environment with Python37
  2. conda activate ankiweb
  3. then from https://github.com/ankicommunity/anki-sync-server download zip, unzip to D:\Soft\Language\Anki\anki-sync-server
  4. cd D:\Soft\Language\Anki\anki-sync-server
  5. (ankiweb) D:\Soft\Language\Anki\anki-sync-server>pip install -r src/requirements.txt Successfully installed beautifulsoup4-4.9.3 decorator-4.4.2 distro-1.5.0 importlib-metadata-3.7.0 markdown-3.3.3 psutil-5.8.0 requests-2.25.1 send2trash-1.5.0 soupsieve-2.2 typing-extensions-3.7.4.3 webob-1.8.6 zipp-3.4.1
  6. edit ankisyncd.conf
  7. install ngnix for windows, and edit conf
  8. cd nginx-1.19.7 start nginx
  9. cd ../src python -m ankisyncd
VikashKothary commented 3 years ago

Did Python 3.8 work for you?

mystiquewolf commented 1 year ago

Hello, I'm not the OP but i have the same issue. Python is 3.10.6. Running Ubuntu 22.04 Jammy inside docker. Error /srv/anki-syncserver/anki-venv/bin/python: Error while finding module specification for 'anki.syncserver' (ModuleNotFoundError: No module named 'anki')

mystiquewolf commented 1 year ago

Well actually i'm using the official https://docs.ankiweb.net/sync-server.html so probably came here by mistake.