Hi,
I’m very new to anvil and notebooks (using them for my MSc)
I’m in the prcess of setting up a web app (with validation) to link to one of Juypter notebooks.
I followed the video to set up the uplink and used pip3. (I’m using Python3.8)
I then pasted the code into my notebook but I get an error:
ModuleNotFoundError Traceback (most recent call last)
in
1 #install link to anvil to enable web based frontend to this script
2
----> 3 import anvil.server
4
5 anvil.server.connect(“my link code here”)
ModuleNotFoundError: No module named ‘anvil’
Any ideas ?
Mike
Hello and welcome,
Could you try these steps and let us know how it goes (they involve setting up a virtual environment)?
In the terminal (assuming mac or linux - see here for windows):
python -m venv my_env
source my_env/bin/activate
pip3 install anvil-uplink
python
In python shell:
import anvil.server
anvil.server.connect("<your uplink key goes here>")
Side note: You can format your code on the forum by following these instructions.
Thanks for getting back to me so quickly.
Failed at first line. The error seems to be referring to Python2.7….I’m using 3.8 ??
Regards,
Mike.
python -m venv my_env
/System/Library/Frameworks/Python.framework/Versions/2.7/Resources/Python.app/Contents/MacOS/Python: No module named venv
When I run them all together:
In your terminal, what do you get when you type:
python --version
Also, when you say you are running Python 3.6, where does you see that? (in an IDE I assume).
In any case, I believe that venv is not available under Python 2, so I’m sure once you can get your system pointed to the right python version, the steps above should work.
Hi Allan,
So the plot thickens:
python —version
Python 2.7.16
I installed 3.8 and I thought I’d pointed my installation at that version and get the following when the pip3 is used (I had to use pip3 as pip wasn’t found)
Version 3.8 in Library path…
Requirement already satisfied: anvil-uplink in /Library/Frameworks/Python.framework/Versions/3.8/lib/python3.8/site-packages (0.3.32)
Requirement already satisfied: argparse in /Library/Frameworks/Python.framework/Versions/3.8/lib/python3.8/site-packages (from anvil-uplink) (1.4.0)
Requirement already satisfied: ws4py in /Library/Frameworks/Python.framework/Versions/3.8/lib/python3.8/site-packages (from anvil-uplink) (0.5.1)
Requirement already satisfied: future in /Library/Frameworks/Python.framework/Versions/3.8/lib/python3.8/site-packages (from anvil-uplink) (0.18.2)
Requirement already satisfied: six in /Library/Frameworks/Python.framework/Versions/3.8/lib/python3.8/site-packages (from anvil-uplink) (1.15.0)
Regards,
Mike.
I would do a google search for “Mac how to set up Python environment” or “Mac switch to Python 3” or something like that.
Allan,
Mac switched to python 3.7.6
Same issue I’m afraid even after pip
pip install anvil-uplink
Requirement already satisfied: anvil-uplink in ./my_env/lib/python3.7/site-packages (0.3.32)
Requirement already satisfied: ws4py in ./my_env/lib/python3.7/site-packages (from anvil-uplink) (0.5.1)
Requirement already satisfied: six in ./my_env/lib/python3.7/site-packages (from anvil-uplink) (1.15.0)
Requirement already satisfied: future in ./my_env/lib/python3.7/site-packages (from anvil-uplink) (0.18.2)
Requirement already satisfied: argparse in ./my_env/lib/python3.7/site-packages (from anvil-uplink) (1.4.0)
(my_env) (base) Mike@iMac wells_row % python --version
Python 3.7.6
I’m not seeing an error there Mike. Looks like it is installed. Try importing again.
Allan,
Can we communicate offline so as not to burden the Q&A ?
I have come across some Anaconda/Python issues that I now cannot work past…
Mike.
Hi @mikecooper49,
If you want private support, that’s available as a paid service. In general, we (and our awesome community) provide free support as long as it’s in public so everyone can benefit from the answer.
This is a forum for discussion about Anvil, and one of the reasons we created Anvil is that setting up your own local Python environment is often a fiddly process. So this topic is already marginal – there’s a limit to how much support we can give with the idiosyncrasies of each user’s widely varying computer!
If you’d like more assistance, I would suggest having a look at our guide to how to ask a good question, and this worked example of making it easier for someone to help you. In particular, if you explained what you had tried, specifically what the error was (and in which Python interpreter, which virtualenv you were running it, etc), you might get a little more help, even though the question is a little off-topic round here
sudo pip3.8 install anvil-uplink … or without sudo
Thanks
uplink - up and running
Onto other challanges…