I am new to IDX and have been fiddling with it for the past few hours so please forgive both my naivety and my general frustration as I have so far found IDX very annoying to work with.
I have created a blank workspace and have (after some trial and error) installed Python3. I am trying to import the “requests” Python package like so:
import requests
but in doing so I received the following error:
ModuleNotFoundError: No module named 'requests'
I have tried adding the “requests” package to my nix environment file and rebuilding the workspace but I am still getting the error:
packages = [
# pkgs.go
pkgs.python311
pkgs.python311Packages.pip
pkgs.python311Packages.requests
# pkgs.nodejs_20
# pkgs.nodePackages.nodemon
# pkgs.python
];
How the heck does one import Python packages in IDX?
I would suggest creating a virtual environment and doing a pip install request…
This should help you
1 Like
Thank you for the advice. So I did that - now it’s telling me that there is no “urllib3” module but when I try to install it it already exists:
Is you python file inside the .idx folder?? Looking at the path it seems to be that way…
Can you try placing the file outside the .IDX folder and trying again
I did have the scrape.py file in the .idx folder. I didn’t think much of it until you brought it up. That said I am still having the issue. I think that I do not fully understand pathing in Linux/IDX
Edit: Disabling the requests package in the dev.nix file and manually uninstalling and reinstalling requests and urllib3 in the venv seems to have fixed the issue… this is very confusing for a newbie like myself but I am assuming there is some issue with how/where the nix package installed the dependences that manually installing in the venv resolved?