07-09-2021 11:51 AM
https://developer.cisco.com/learning/lab/collab-webex-chatops-bot-itp/step/3
I followed all of these instructions and can't seem to work. Even though requests is installed I keep getting error. I don't know what else to try. I deleted and tried all the instructions multiple times to be sure I didn't miss a step. Are these out of date or am I just not doing something right?
I was going to attach the file but I didn't make any changes.
I am on step 2 where it says right click and Run Python File in terminal and get this error below.
Can anyone help?
--
File "c:\Projects2020\DevNet\devnet-express-cloud-collab-code-samples\itp\collab-spark-chatops-bot-itp\chatops.py", line 1, in <module>
import requests
ModuleNotFoundError: No module named 'requests'
--
Solved! Go to Solution.
07-12-2021 08:22 AM
I was able to get it to work. I tried 'pip freeze' but still was getting error. I had to copy the Lib\site-packages to my Python39 Lib\site-packages folder and then it worked. This seems like more work than it should be needed. All this is new to me because I am a C# developer, but it seems there should be some way to force VS Code to use your env lib folder and not the python lib folder, or maybe change python to look in the env folder. I don't know but I did get it to work.
Thank you for your help.
07-10-2021 02:49 AM
Hey @tammi.anthony sure - at the top of the Learning Lab you will see some text which says "How To Setup Your Own Computer" if you click this it will open a new box. In there you will find the fix.
Install the Python3 'requests' Library To install Requests for Python3 , use this command line: pip3 install requests For Windows you may need to use: pip install requests
The error you see is due to you not having the Python request library installed and when the code tries to run your code cannot find the requirement provided by this libary.
Hope this helps!
07-12-2021 05:12 AM
I did that but it will not run in VS Code. Even though I see requests is installed. I'm wondering if it's a VS Code issue. It doesn't seem to see my latest versions of any installs.
07-12-2021 06:13 AM
I accidently marked this as solved. oops
This is what I get when I run pip3 install requests
$ pip3 install requests Requirement already satisfied: requests in c:\projects2020\devnet\devnet-express-cloud-collab-code-samples\itp\collab-spark-chatops-bot-itp\env\lib\site-packages (2.23.0) Requirement already satisfied: urllib3!=1.25.0,!=1.25.1,<1.26,>=1.21.1 in c:\projects2020\devnet\devnet-express-cloud-collab-code-samples\itp\collab-spark-chatops-bot-itp\env\lib\site-packages (from requests) (1.25.9) Requirement already satisfied: certifi>=2017.4.17 in c:\projects2020\devnet\devnet-express-cloud-collab-code-samples\itp\collab-spark-chatops-bot-itp\env\lib\site-packages (from requests) (2020.4.5.2) Requirement already satisfied: chardet<4,>=3.0.2 in c:\projects2020\devnet\devnet-express-cloud-collab-code-samples\itp\collab-spark-chatops-bot-itp\env\lib\site-packages (from requests) (3.0.4) Requirement already satisfied: idna<3,>=2.5 in c:\projects2020\devnet\devnet-express-cloud-collab-code-samples\itp\collab-spark-chatops-bot-itp\env\lib\site-packages (from requests) (2.9)
It's stating it's already installed.
07-12-2021 06:15 AM
When I right click and Run Python File per the instructions I get this error.
PS C:\Projects2020\DevNet\devnet-express-cloud-collab-code-samples\itp\collab-spark-chatops-bot-itp> & C:/Python39/python.exe c:/Projects2020/DevNet/devnet-express-cloud-collab-code-samples/itp/collab-spark-chatops-bot-itp/chatops.py Traceback (most recent call last): File "c:\Projects2020\DevNet\devnet-express-cloud-collab-code-samples\itp\collab-spark-chatops-bot-itp\chatops.py", line 1, in <module> import requests ModuleNotFoundError: No module named 'requests' PS C:\Projects2020\DevNet\devnet-express-cloud-collab-code-samples\itp\collab-spark-chatops-bot-itp>
07-12-2021 06:23 AM
This is often because the Python interpreter that VS Code uses for inspecting your project (to provide auto-complete) and the interpreter used for running your code in Terminal is different (hence, in different environment and having their own list of installed packages).
https://code.visualstudio.com/docs/python/environments
07-12-2021 06:32 AM
thank you. When I run source .venv/Scripts/activate it says source can't be found.
PS C:\Projects2020\DevNet\devnet-express-cloud-collab-code-samples\itp\collab-spark-chatops-bot-itp> python -m venv .venv
PS C:\Projects2020\DevNet\devnet-express-cloud-collab-code-samples\itp\collab-spark-chatops-bot-itp> source .venv/Scripts/activate source : The term 'source' is not recognized as the name of a cmdlet, function, script file, or operable program. Check the spelling of the name, or if a path was included, verify that the path is correct and try again. At line:1 char:1 + source .venv/Scripts/activate + ~~~~~~ + CategoryInfo : ObjectNotFound: (source:String) [], CommandNotFoundException + FullyQualifiedErrorId : CommandNotFoundException
I don't get the prompt like the instructions say.
07-12-2021 06:50 AM
I got past that error. I guess in VS you don't say source. I was never prompted to use the environment like the instructions say, but I am using the environment and still get that error.
PS C:\Projects2020\DevNet\devnet-express-cloud-collab-code-samples\itp\collab-spark-chatops-bot-itp> .venv/scripts/activate (.venv) PS C:\Projects2020\DevNet\devnet-express-cloud-collab-code-samples\itp\collab-spark-chatops-bot-itp> & C:/Python39/python.exe c:/Projects2020/DevNet/devnet-express-cloud-collab-code-samples/itp/collab-spark-chatops-bot-itp/chatops.py Traceback (most recent call last): File "c:\Projects2020\DevNet\devnet-express-cloud-collab-code-samples\itp\collab-spark-chatops-bot-itp\chatops.py", line 1, in <module> import requests ModuleNotFoundError: No module named 'requests' (.venv) PS C:\Projects2020\DevNet\devnet-express-cloud-collab-code-samples\itp\collab-spark-chatops-bot-itp>
07-12-2021 08:03 AM
@tammi.anthony once you have entered your virtual env - can you issue a `pip freeze' or 'pip list'?
07-12-2021 08:22 AM
I was able to get it to work. I tried 'pip freeze' but still was getting error. I had to copy the Lib\site-packages to my Python39 Lib\site-packages folder and then it worked. This seems like more work than it should be needed. All this is new to me because I am a C# developer, but it seems there should be some way to force VS Code to use your env lib folder and not the python lib folder, or maybe change python to look in the env folder. I don't know but I did get it to work.
Thank you for your help.
07-12-2021 09:34 AM
@tammi.anthony awesome congrats - if you get stuck on issues such as these you can also talk live to our team in the Webex room here for support --> https://developer.cisco.com/site/devnet-chat/
Discover and save your favorite ideas. Come back to expert answers, step-by-step guides, recent topics, and more.
New here? Get started with these tips. How to use Community New member guide