Hello, i am trying to configure an uplink server and i have this code on visual studio:
import anvil.server
import csv
@anvil.server.callable
def load_csv_data():
some_data = []
with open(r"C:\Users\Tiago\Desktop\valoresm2.csv", newline='') as csvfile:
csvreader = csv.reader(csvfile)
for row in csvreader:
some_data.append(row)
return some_data
anvil.server.connect("----------------mykey--------------------")
try:
anvil.server.wait_forever()
except KeyboardInterrupt:
print("User called to quit.")
input("<< PRESS RETURN >>")
exit()
I have the correct key on the mykey place.
Im having an unresolved import error on the first line, i already pip installed anvil and pip installed anvil-uplink, i tried this code on python 3.9 and 3.7…
Anyone can help me?
Did you python -m pip install anvil-uplink
after you had already started visual studio? If so, you might want to restart to make the linter recognize the package.
Also possible that your visual studio is not pointing to the same version of python as you have installed anvil-server on?
These are both shots in the dark, but I have done this on a few machines and had the same first time use errors as you described.
you might have multiple versions of python installed, and pip may be installing it under the incorrect PATH python -m usually fixes this, but not always
mine is installed already obviously so it just tells me it is already installed.
a problem could be that you seem to have pip installed both anvil and anvil-uplink
these may have conflicts since the pypi package named anvil is not associated with anvil.works.
Things to try:
pip uninstall anvil
pip3 install anvil-uplink
# sometimes pip3 may be required depending on how python is running locally
also check out this thread
in your script
import anvil
print(anvil.__file__)
# you may not be importing the anvil-uplink pypi package but something else
# go to this file and see what it is - change the name of the file, rinse and repeat
print(dir(anvil))
# BlobMedia, Button, ...
# if you don't get the obvious anvil dir then you are importing the wrong anvil
You can also try running the uplink script in a virtual environment.
The advantage here is that you install packages within the virtual environment rather than globally.