Jupyter unable to use Vartests that’s found in my site-packages - python

I have Anaconda installed in my system. I have used Jupyter notebook to install vartests package using “!pip install vartests”. In my site-packages folder inside Anaconda/lib, I am able to find a directory for vartests, which means the package has been installed. But when I try to import it in the same jupyter notebook, it says import error.
I’ve tried using “!{sys.executable} -m pip install vartests” but it doesn’t help. I’ve followed things written in “Installing Python Packages from Jupyter Notebook” by Jake VanderPlas as well.
One thing, my “!type -a python” doesn’t give me anything. Is there a way out from this?

Related

Installing Rasterio

I tried installing Rasterio library using command- pip install rasterio and also used conda commands in anaconda cmd, both are didn't worked and it's taking too long to install so I aborted the process. Let me know in detail how to install raserio library for python?
I tried with installing GDAL and raterio whl file by using pip commands. It got installed, but when I tried to import module- it's giving me an error saying No module found. Please help to fix this.
Thanks in advance
I just had the similar problem, and tl:dr the issue for me was multiple environments, like Ameya said. Here's a longer version of Ameya's spot-on answer with steps to diagnose and fix.
Without realizing it, I had two environments going on: my jupyter notebook was running python 3.10 and my global python was running 3.9, and each was looking for site-packages in different locations (/opt/homebrew/Cellar/jupyterlab/3.4.7/libexec/lib/python3.10/site-packages vs /Users//Library/Python/3.9/lib/site-packages).
This happened because I had trouble with getting python and specifically jupyterlab running on Monterey and the only fix for me was using homebrew to manage the packages. Anything I installed with brew from the command line, went into /opt/homebrew/Cellar... etc and could be seen by my jupyter notebook. Anything I used pip install to get from within an open notebook also went onto this path that my notebook could see. But anything I used pip install from the command line to get, went to the path of the global environment's site packages. Then, my jupyter notebook couldn't see them.
You don't mention that you are using jupyter notebook but perhaps something analogous could happen between multiple environments for you.
You can check if this is the case for you by doing the following:
start python from the command line
import sys
run sys.path
start jupyter notebook, or start python from your other environment
same thing, import sys, run sys.path
Are they the same? If not, probably pip is putting your rasterio in other python env site-packages.
To fix, you can either pip install from within your preferred environment, or copy and paste the site packages corresponding to rasterio from one site-packages location to the other.

Why does it say that pygame is already installed but I can't use it [duplicate]

Running on Windows 10, I have Python 3.7.3 installed to my c/users/myUser/appdata/local/programs folder.
When I use PIP to install a package, it seems to run fine, but when I use "import package" in python it doesn't recognize that package. What would cause this?
Running 'python --version' works and also running 'pip --version' works.
PIP shows up in my c/users/myUser/appdata/local/programs/python37-32/lib/site-packages/pip folder.
UPDATE:
So I was looking through files to determine where the libraries are located that do work with my python. The folder is located in Python/Python37-32/Lib. All of those currently work when importing. However when I do anything with PIP it does not add anything to that folder.
I noticed there are a couple different PIP executables within Python/Python37-32/Scripts which include pip.exe, pip3.exe, and pip3.7.exe. I tried using "pip3.7 install numpy" which also did not work.
I noticed when trying to add an existing package its pointing to the Python37-32/lib/site-packages folder.
SOLUTION:
I removed python from my machine, and reinstalled it. I had the same problem. What I done to fix this was to use
PS
python -m pip install --user package
Also I appended my PATH environment variable with
cmd
setx path "%path%;C:\Users\MyUser\AppData\Roaming\Python\Python38\Scripts"
That seemed to have taken care of my issue. Now when I install a package with PIP I can reference it through python.

Python module not found after installing anaconda

Hope everyone is doing fine :)
I'm new to python, so I'm having trouble cause I've installed anaconda (for machine learning) and now, my local projects in VS Code with python, don't find modules installed from pip install.
I've searched online and I guess it has something to do with the path... Here's the path when I install the module:
user_stuff.../opt/anaconda3/lib/python3.9/site-packages
I want to install modules into my project on desktop, here's the path:
user_stuff.../Desktop/python-project
I keep getting this error when trying to import:
ModuleNotFoundError: No module named 'qrcode'
How do I change this? It's really frustrating :(
I guess your pip is referring to the pip provided by the system, it should be now referring to the pip provided by anaconda.
$ which pip
$ alias pip="/Users/my-username/anaconda3/bin/pip"
$ pip install qrcode
Do you use jupyter notebook in vs code? I prefer it because there you can easily select the environment you are using. And if you want to pip install anything in a environment you have to first activate it in the console with conda activate env name

PIP install package - installed but python is not importing

Running on Windows 10, I have Python 3.7.3 installed to my c/users/myUser/appdata/local/programs folder.
When I use PIP to install a package, it seems to run fine, but when I use "import package" in python it doesn't recognize that package. What would cause this?
Running 'python --version' works and also running 'pip --version' works.
PIP shows up in my c/users/myUser/appdata/local/programs/python37-32/lib/site-packages/pip folder.
UPDATE:
So I was looking through files to determine where the libraries are located that do work with my python. The folder is located in Python/Python37-32/Lib. All of those currently work when importing. However when I do anything with PIP it does not add anything to that folder.
I noticed there are a couple different PIP executables within Python/Python37-32/Scripts which include pip.exe, pip3.exe, and pip3.7.exe. I tried using "pip3.7 install numpy" which also did not work.
I noticed when trying to add an existing package its pointing to the Python37-32/lib/site-packages folder.
SOLUTION:
I removed python from my machine, and reinstalled it. I had the same problem. What I done to fix this was to use
PS
python -m pip install --user package
Also I appended my PATH environment variable with
cmd
setx path "%path%;C:\Users\MyUser\AppData\Roaming\Python\Python38\Scripts"
That seemed to have taken care of my issue. Now when I install a package with PIP I can reference it through python.

Path confusion using Conda, PIP, and Jupyter notebook at the same time

I've been using conda and jupyter notebook for a while now and recently I need some packages that are only available for install via pip. My understanding was that they are completely compatible and transparent with each other but apparently not.
I did a pip install pydicom and when I tried to do an import pydicom in my Jupyter Notebook, it says No module named pydicom.
In command prompt (using a Windows machine here) I ran conda list and I see pydicom is listed and marked as < pip >.
In my Jupyter notebook, this is my sys.executable output:
C:\Users\USERNAME\AppData\Local\Continuum\Anaconda2\python.exe
Is that normal/correct???
Disclaimer: I'm thoroughly confused by how the paths, environment, and dependencies work in conda and pip. I can't find a good tutorial or explanation how conda/pip work behind the scenes. Any pointers will be greatly appreciated!
While the package is named pydicom, you need to import dicom:
import dicom
You can also in install pydicom via conda. You need to provide the channel 'conda-forge`:
conda install -c conda-forge pydicom
You can find more packages a https://anaconda.org/. Just enter the package name in the search window. If the package is available you will see the channel you can with the -c option.

Categories