I'm using the programmatic download of python (v 3.12.5) but an error occurred:
Error occurred while running in a sync context.
TypeError: nt._path_exists() takes no keyword arguments
[ERROR] Unable to download file
[WARNING] A manifest was created, but no files were downloaded
Created by Victoria Pozzi Ruiz Epi-Lab Resolved! The problem was definitely the version. Thanks for the support Hi @Epi-Lab ,
Thanks for looking into this! Apologies, I should have noticed this sooner, but the python client currently doesn't support Python 3.12, could you downgrade to Python 3.11 to see if it works?
Hi @thomas.yu ,
Sorry for the late reply, It took me some time to contact my institution. They verified all IP directions and there are no restriction access or traffic problems. However, I get no results when I try to connect:
>>> import synapseclient
>>> syn = synapseclient.Synapse()
>>> syn.login(authToken="")
Welcome, Epi-Lab!
>>> import ping3
>>> from ping3 import ping
>>> ping ('52.45.221.235')
>>> ping ('52.7.75.49')
>>> ping ('3.234.175.106')
>>> ping ('3.88.97.84')
>>> ping ('44.194.236.113')
>>> ping ('54.205.219.117')
>>> ping ('34.234.4.162')
>>> ping ('34.233.95.87')
>>> ping ('54.166.5.127')
>>> ping ('54.226.68.127')
>>> ping ('3.215.225.38')
>>> ping ('44.194.89.171')
>>> syn.get("syn21683345")
[ERROR] Error occurred while running in a sync context.
Traceback (most recent call last):
File "C:\Users\vp\AppData\Local\Programs\Python\Python312\Lib\site-packages\synapseclient\core\async_utils.py", line 93, in wrap_async_to_sync
return asyncio.run(coroutine)
^^^^^^^^^^^^^^^^^^^^^^
File "C:\Users\vp\AppData\Local\Programs\Python\Python312\Lib\asyncio\runners.py", line 194, in run
return runner.run(main)
^^^^^^^^^^^^^^^^
File "C:\Users\vp\AppData\Local\Programs\Python\Python312\Lib\asyncio\runners.py", line 118, in run
return self._loop.run_until_complete(task)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "C:\Users\vp\AppData\Local\Programs\Python\Python312\Lib\asyncio\base_events.py", line 687, in run_until_complete
return future.result()
^^^^^^^^^^^^^^^
File "C:\Users\vp\AppData\Local\Programs\Python\Python312\Lib\site-packages\synapseclient\core\download\download_functions.py", line 136, in download_file_entity
download_path = resolve_download_path_collisions(
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "C:\Users\vp\AppData\Local\Programs\Python\Python312\Lib\site-packages\synapseclient\core\download\download_functions.py", line 921, in resolve_download_path_collisions
if os.path.exists(path=download_path):
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
TypeError: nt._path_exists() takes no keyword arguments
Traceback (most recent call last):
File "", line 1, in
File "C:\Users\vp\AppData\Local\Programs\Python\Python312\Lib\site-packages\synapseclient\client.py", line 1364, in get
return_data = self._getWithEntityBundle(
^^^^^^^^^^^^^^^^^^^^^^^^^^
File "C:\Users\vp\AppData\Local\Programs\Python\Python312\Lib\site-packages\synapseclient\client.py", line 1551, in _getWithEntityBundle
wrap_async_to_sync(
File "C:\Users\vp\AppData\Local\Programs\Python\Python312\Lib\site-packages\synapseclient\core\async_utils.py", line 99, in wrap_async_to_sync
raise ex
File "C:\Users\vp\AppData\Local\Programs\Python\Python312\Lib\site-packages\synapseclient\core\async_utils.py", line 93, in wrap_async_to_sync
return asyncio.run(coroutine)
^^^^^^^^^^^^^^^^^^^^^^
File "C:\Users\vp\AppData\Local\Programs\Python\Python312\Lib\asyncio\runners.py", line 194, in run
return runner.run(main)
^^^^^^^^^^^^^^^^
File "C:\Users\vp\AppData\Local\Programs\Python\Python312\Lib\asyncio\runners.py", line 118, in run
return self._loop.run_until_complete(task)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "C:\Users\vp\AppData\Local\Programs\Python\Python312\Lib\asyncio\base_events.py", line 687, in run_until_complete
return future.result()
^^^^^^^^^^^^^^^
File "C:\Users\vp\AppData\Local\Programs\Python\Python312\Lib\site-packages\synapseclient\core\download\download_functions.py", line 136, in download_file_entity
download_path = resolve_download_path_collisions(
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "C:\Users\vp\AppData\Local\Programs\Python\Python312\Lib\site-packages\synapseclient\core\download\download_functions.py", line 921, in resolve_download_path_collisions
if os.path.exists(path=download_path):
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
TypeError: nt._path_exists() takes no keyword arguments
As you can see, I made a syntax modification because if I use your code:
>>> ping 52.7.75.49
File "", line 1
ping 52.7.75.49
^^^^
SyntaxError: invalid syntax
Do you have any ideas?
Thank you so much,
Hi @Epi-Lab ,
Thanks, I see that you have uploaded your personal access token, please ensure that is deleted so other users can't access your account.
This is very helpful. From my end. we are able to run this command on windows, mac and linux
```
import synapseclient
syn = synapseclient.login()
# Welcome, Thomas Yu!
syn.get("syn21683345")
# Downloaded syn21683345 to /Users/tyu/.synapseCache/238/144420238/data_guide (31).pdf
```
So it's probably not a synapse python client issue. Could you take a look at this documentation: https://help.synapse.org/docs/Synapse-Infrastructure.2835382273.html
Apologies for the inconveniences as we work through this issue, I strongly suspect this is a networking issue where certain IP's may be blocked by your institution or network?
Could you try:
```
ping 52.45.221.235
# PING 52.45.221.235 (52.45.221.235): 56 data bytes
# Request timeout for icmp_seq 0
# Request timeout for icmp_seq 1
# ^C
# --- 52.45.221.235 ping statistics ---
# 3 packets transmitted, 0 packets received, 100.0% packet loss
ping 52.7.75.49
ping 3.234.175.106
ping 3.88.97.84
ping 44.194.236.113
ping 54.205.219.117
```
And paste the results. You would need to ping each of these endpoints for download to work. Hi @thomas.yu ,
The only way I can log in successfully (Python) is by using:
import synapseclient
syn = synapseclient.Synapse()
syn.login(authToken="eyJ0eXAiOiJKV1QiLCJraWQiOiJXN05OOldMSlQ6SjVSSzpMN1RMOlQ3TDc6M1ZYNjpKRU9VOjY0NFI6VTNJWDo1S1oyOjdaQ0s6RlBUSCIsImFsZyI6IlJTMjU2In0.eyJhY2Nlc3MiOnsic2NvcGUiOlsidmlldyIsImRvd25sb2FkIiwibW9kaWZ5Il0sIm9pZGNfY2xhaW1zIjp7fX0sInRva2VuX3R5cGUiOiJQRVJTT05BTF9BQ0NFU1NfVE9LRU4iLCJpc3MiOiJodHRwczovL3JlcG8tcHJvZC5wcm9kLnNhZ2ViYXNlLm9yZy9hdXRoL3YxIiwiYXVkIjoiMCIsIm5iZiI6MTcyNDA2MzE5MCwiaWF0IjoxNzI0MDYzMTkwLCJqdGkiOiIxMTIxMSIsInN1YiI6IjM1MTIxMTMifQ.EdGfK70YbyxgpR1qDIi83WkdH8WkkuPELUh8P2mTJ-tSMLxzIq4qGgoiOiH_8YMZVV88GQQ25SEbCV3xnItGq7q06tt0C2VI18HGtXKlOg3jP6ztaxF3SwoFzzb83IpO1mnqltit3hq0B-hTTq8GKqyjZCGJ4fZ8ZvBjXNKpGaYFu2NjM-Y5yC8fdImKMsXXmijdhzVHcULzXrivEtOJlCsFH1VVljK7dpQ4pCsWu4VX8BSgYjXzKqr5f9VNsSwwFBFv47G0h1fV9catMV7epvPI328w5y_DrIMcOQezEcjm_WaQnYJuSilomJ7oFlMZyZQT9C7mdXgRVus1G38LSw")
Welcome, Epi-Lab!
If I try your code, this is the message:
>>> import synapseclient
>>> syn = synapseclient.login(auth token= eyJ0eXAiOiJKV1QiLCJraWQiOiJXN05OOldMSlQ6SjVSSzpMN1RMOlQ3TDc6M1ZYNjpKRU9VOjY0NFI6VTNJWDo1S1oyOjdaQ0s6RlBUSCIsImFsZyI6IlJTMjU2In0.eyJhY2Nlc3MiOnsic2NvcGUiOlsidmlldyIsImRvd25sb2FkIiwibW9kaWZ5Il0sIm9pZGNfY2xhaW1zIjp7fX0sInRva2VuX3R5cGUiOiJQRVJTT05BTF9BQ0NFU1NfVE9LRU4iLCJpc3MiOiJodHRwczovL3JlcG8tcHJvZC5wcm9kLnNhZ2ViYXNlLm9yZy9hdXRoL3YxIiwiYXVkIjoiMCIsIm5iZiI6MTcyNDA2MzE5MCwiaWF0IjoxNzI0MDYzMTkwLCJqdGkiOiIxMTIxMSIsInN1YiI6IjM1MTIxMTMifQ.EdGfK70YbyxgpR1qDIi83WkdH8WkkuPELUh8P2mTJ-tSMLxzIq4qGgoiOiH_8YMZVV88GQQ25SEbCV3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^^^^^^^^
SyntaxError: invalid syntax. Perhaps you forgot a comma?
Regarding your second code, I have added syn.login in the middle just for login, and this is the result:
>>> import synapseclient
>>> syn = synapseclient.Synapse()
>>>syn.login(authToken="eyJ0eXAiOiJKV1QiLCJraWQiOiJXN05OOldMSlQ6SjVSSzpMN1RMOlQ3TDc6M1ZYNjpKRU9VOjY0NFI6VTNJWDo1S1oyOjdaQ0s6RlBUSCIsImFsZyI6IlJTMjU2In0.eyJhY2Nlc3MiOnsic2NvcGUiOlsidmlldyIsImRvd25sb2FkIiwibW9kaWZ5Il0sIm9pZGNfY2xhaW1zIjp7fX0sInRva2VuX3R5cGUiOiJQRVJTT05BTF9BQ0NFU1NfVE9LRU4iLCJpc3MiOiJodHRwczovL3JlcG8tcHJvZC5wcm9kLnNhZ2ViYXNlLm9yZy9hdXRoL3YxIiwiYXVkIjoiMCIsIm5iZiI6MTcyNDA2MzE5MCwiaWF0IjoxNzI0MDYzMTkwLCJqdGkiOiIxMTIxMSIsInN1YiI6IjM1MTIxMTMifQ.EdGfK70YbyxgpR1qDIi83WkdH8WkkuPELUh8P2mTJ-tSMLxzIq4qGgoiOiH_8YMZVV88GQQ25SEbCV3xnItGq7q06tt0C2VI18HGtXKlOg3jP6ztaxF3SwoFzzb83IpO1mnqltit3hq0B-hTTq8GKqyjZCGJ4fZ8ZvBjXNKpGaYFu2NjM-Y5yC8fdImKMsXXmijdhzVHcULzXrivEtOJlCsFH1VVljK7dpQ4pCsWu4VX8BSgYjXzKqr5f9VNsSwwFBFv47G0h1fV9catMV7epvPI328w5y_DrIMcOQezEcjm_WaQnYJuSilomJ7oFlMZyZQT9C7mdXgRVus1G38LSw")
Welcome, Epi-Lab!
>>> syn.get("syn21683345")
[ERROR] Error occurred while running in a sync context.
Traceback (most recent call last):
File "C:\Users\vp\AppData\Local\Programs\Python\Python312\Lib\site-packages\synapseclient\core\async_utils.py", line 93, in wrap_async_to_sync
return asyncio.run(coroutine)
^^^^^^^^^^^^^^^^^^^^^^
File "C:\Users\vp\AppData\Local\Programs\Python\Python312\Lib\asyncio\runners.py", line 194, in run
return runner.run(main)
^^^^^^^^^^^^^^^^
File "C:\Users\vp\AppData\Local\Programs\Python\Python312\Lib\asyncio\runners.py", line 118, in run
return self._loop.run_until_complete(task)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "C:\Users\vp\AppData\Local\Programs\Python\Python312\Lib\asyncio\base_events.py", line 687, in run_until_complete
return future.result()
^^^^^^^^^^^^^^^
File "C:\Users\vp\AppData\Local\Programs\Python\Python312\Lib\site-packages\synapseclient\core\download\download_functions.py", line 136, in download_file_entity
download_path = resolve_download_path_collisions(
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "C:\Users\vp\AppData\Local\Programs\Python\Python312\Lib\site-packages\synapseclient\core\download\download_functions.py", line 921, in resolve_download_path_collisions
if os.path.exists(path=download_path):
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
TypeError: nt._path_exists() takes no keyword arguments
Traceback (most recent call last):
File "", line 1, in
File "C:\Users\vp\AppData\Local\Programs\Python\Python312\Lib\site-packages\synapseclient\client.py", line 1364, in get
return_data = self._getWithEntityBundle(
^^^^^^^^^^^^^^^^^^^^^^^^^^
File "C:\Users\vp\AppData\Local\Programs\Python\Python312\Lib\site-packages\synapseclient\client.py", line 1551, in _getWithEntityBundle
wrap_async_to_sync(
File "C:\Users\vp\AppData\Local\Programs\Python\Python312\Lib\site-packages\synapseclient\core\async_utils.py", line 99, in wrap_async_to_sync
raise ex
File "C:\Users\vp\AppData\Local\Programs\Python\Python312\Lib\site-packages\synapseclient\core\async_utils.py", line 93, in wrap_async_to_sync
return asyncio.run(coroutine)
^^^^^^^^^^^^^^^^^^^^^^
File "C:\Users\vp\AppData\Local\Programs\Python\Python312\Lib\asyncio\runners.py", line 194, in run
return runner.run(main)
^^^^^^^^^^^^^^^^
File "C:\Users\vp\AppData\Local\Programs\Python\Python312\Lib\asyncio\runners.py", line 118, in run
return self._loop.run_until_complete(task)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "C:\Users\vp\AppData\Local\Programs\Python\Python312\Lib\asyncio\base_events.py", line 687, in run_until_complete
return future.result()
^^^^^^^^^^^^^^^
File "C:\Users\vp\AppData\Local\Programs\Python\Python312\Lib\site-packages\synapseclient\core\download\download_functions.py", line 136, in download_file_entity
download_path = resolve_download_path_collisions(
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "C:\Users\vp\AppData\Local\Programs\Python\Python312\Lib\site-packages\synapseclient\core\download\download_functions.py", line 921, in resolve_download_path_collisions
if os.path.exists(path=download_path):
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
TypeError: nt._path_exists() takes no keyword arguments
>>>
Let me know if you need more information
Hi @Epi-Lab,
Thanks - this is helpful. One last thing, could you provide me with the output of the entire output (stdout) and the full command you ran with your password redacted
```
import synapseclient
syn = synapseclient.login(auth token= PAT)
```
Are you able to log in? It should say something like "welcome, Epi-Lab"
Separately let's try this
```
import synapseclient
syn = synapseclient.Synapse()
syn.get("syn21683345")
```
Again, please paste the entire command and all of your output. Apologies for the inconvenience, I have a couple of guesses of what it could be but we test our package against windows, Mac and Linux so having a windows machine shouldn't be the problem. Hi @thomas.yu ,
Using command line client the code >synapse get syn... doesn't work for me. I have to write >py -m synapseclient get syn... to have an answer. It ask me for my token password and after that an error occurred:
synapseclient.core.exceptions.SynapseHTTPError: 400 Client Error: Bad Request
400 Bad Request
Bad Request
Your browser sent a request that this server could not understand.
If I try to use syn.get("syn...") on Python I have the same problem describe above:
[ERROR] Error occurred while running in a sync context.
TypeError: nt._path_exists() takes no keyword arguments
I'm for sure doing something wrong but I don't know what. I didn't mention that I'm using Windows, maybe that's the problem. Hi @Epi-Lab
Not a problem. So each file, folder, or project in synapse has a Synapse id. The two links you provided are synapse files . You can download them this way (using the command line client)
```
# command line client installed when you install the python client
synapse get syn25191244
# python client
import synapseclient
syn = synapseclient.login()
syn.get("syn25191244")
```
The above downloads a file. Alternatively, if you have folder of files you an do
```
# command line client
synapse get -r synNNNN
# python client
import synapseutils
import synapseclient
syn = synapseclient.login()
synapseutils.syncFromSynapse(syn, ?synNNNN")
```
Here the synNNNN should be replaced with a synapse id of a folder.
The download cart function that you used works for me, but I didn't test it on the list of files you added to your download so it's not a fair comparison. This is why I am suggesting for you to not use the download cart function to see if it is an error we can reproduce on an individual file or folder level.
Let me know if any of this is unclear. Hi @thomas.yu ,
I am trying different file lists and I have the same problem. Try for example this two: syn25191244.1 and syn25191323.1.
Regarding the tutorial, I feel that I don't understand properly the way Synapse works. The code of the tutorial allows me to download the content of a project held in my account: FOLDER_NAME_TO_SYNC = "biospecimen_experiment_1", but I don't know how to change it to download the cart. Alternatively, I am not sure if it is possible to add the files that I want to download to my project platform.
Thanks for the help, Hi @Epi-Lab ,
Could you provide a list of files you are trying to download? Unfortunately, we cannot fully reproduce the bug without the list of files along with permissions to download the files. My recommendation is to not use `get_download_list` function, but actually follow some of the tips here: https://python-docs.synapse.org/tutorials/python/download_data_in_bulk to download your files. Apologies for any inconveniences.
Sorry @thomas.yu , maybe you were asking about my Synapse client version. It is 4.4.0. Hi @thomas.yu ,
I'm running
import synapseclient
syn = synapseclient.Synapse()
syn.login(authToken="my token password")
dl_list_file_entities = syn.get_download_list()
to download all files listed in the cart. The Python version is 3.12.5. Thanks, Hi @Epi-Lab ,
Thanks for using Synapse, could you provide the entire command you ran and version of the python client?