Modules installed globally not found in VS Code Jupyter Notebook - python-3.x

I've installed several Python modules from PyPi globally on Mac OS using pip3. Running pip3 list confirms that they are installed:
user#users-MacBook-Pro SER-neural-net % pip3 list
Package Version
------------------ ---------
appdirs 1.4.4
audioread 3.0.0
...
librosa 0.9.2
numpy 1.23.4
pip 22.3.1
scikit-learn 1.1.3
scipy 1.9.3
sklearn 0.0.post1
sounddevice 0.4.5
soundfile 0.11.0
torch 1.13.0
...
From the integrated terminal in VS Code where I am running the notebook, I have run the following commands to determine which Python interpreter to use:
user#users-MacBook-Pro SER-neural-net % which pip3
/usr/local/bin/pip3
user#users-MacBook-Pro SER-neural-net % which python3
/usr/local/bin/python3
user#users-MacBook-Pro SER-neural-net % python3 --version
Python 3.7.9
I have selected the appropriate interpreter at the top right of Jupyter Notebook view in VS Code:
But the modules confirmed to be installed for this interpreter are not found:
What has gone wrong?

use this:
python3 -m pip install --user (library)
for example:
python3 -m pip install --user pandas

Related

Cannot install Scipy in FreeBSD 13 with Python 3.10

I am trying install scipy in FreeBSD 13. I have built python 3.10 on FreebSD 13 and managed to install pandas, matplotlib and numpy on a virtual environment which has python 3.10. However, when I try to install sklearn or scipy I get an error saying scipy could not be installed.
Here it is below for when doing pip install scipy. I get the same error more or less when trying to install sklearn.
ERROR: Failed building wheel for scipy
Failed to build scipy
ERROR: Could not build wheels for scipy, which is required to install pyproject.toml-based projects
Command errored out with exit status 1: /home/schroter/.pymain/dataViz/bin/python3 /tmp/pip-standalone-pip-d3nnvp2f/__env_pip__.zip/pip install --ignore-installed --no-user --prefix /tmp/pip-build-env-xp_669rf/overlay --no-warn-script-location --no-binary :none: --only-binary :none: -i https://pypi.org/simple -- setuptools wheel 'Cython>=0.28.5' 'oldest-supported-numpy; python_version!='"'"'3.7'"'"' or platform_machine=='"'"'aarch64'"'"' or platform_system=='"'"'AIX'"'"' or platform_python_implementation == '"'"'PyPy'"'"'' 'numpy==1.14.6; python_version=='"'"'3.7'"'"' and platform_machine!='"'"'aarch64'"'"' and platform_system!='"'"'AIX'"'"' and platform_python_implementation != '"'"'PyPy'"'"'' 'scipy>=1.1.0' Check the logs for full command output.
My pip list is as below:
(dataViz) schroter#SCHROTER:~ % pip list
Package Version
---------------- -------
cycler 0.11.0
kiwisolver 1.1.0
matplotlib 3.4.3
numpy 1.21.4
pandas 1.3.4
Pillow 8.4.0
pip 21.3.1
pyparsing 3.0.6
python-dateutil 2.8.2
pytz 2021.3
semantic-version 2.8.5
setuptools 58.5.3
setuptools-rust 0.12.1
six 1.16.0
toml 0.10.2
wheel 0.37.0
Would anyone be able to help me in this regards please?
Thanks & Best Regards
Schroter
Reuse system package
# install system-wide version in site-packages
doas pkg install py38-scipy-1.8.0
# create a virtualenv with site-packages included
python -m venv --system-site-packages .venv
Drawback is you'll get all packages from site-packages, however you can tackle that by
doas pkg install py38-scipy-1.8.0
python -m venv .venv
YOUR_PYTHON_VERSION= SET IT HERE
ln -s $(python -c 'import lxml, os.path; print(os.path.dirname(lxml.__file__)') ./.venv/lib/$YOUR_PYTHON_VERSION/site-packages
borrowed from https://stackoverflow.com/a/13719417
Regular Installation (TODO)
Haven't figured out it yet, but maybe someone else will, so putting here 2 links which might be helpful
https://forums.freebsd.org/threads/python-scipy-with-python3-x-on-freebsd-11.59009/
https://reviews.freebsd.org/D23447
Have you tried to install scipy from freebsd ports? The freebsd ports contain patches to make the code compile on FreeBSD.

I can't install python modules on Apple Silicon

I have macbook air m1 and I can't install python modules like numpy, matplotlib.
I install python3.8 with homebrew then install virtaulenv. In venv, when I run 'pip install numpy' the error shows up:
'... ERROR: Failed building wheel for numpy
Failed to build numpy
ERROR: Could not build wheels for numpy which use PEP 517 and cannot be installed directly'
I tried 'pip install --upgrade pip setuptools wheel' doesn't work. Please help.
Install python 3.9.1 from python.org (ARM version)
Then, for Numpy:
python3 -m pip install cython
python3 -m pip install --no-binary :all: --no-use-pep517 numpy==1.20rc1
Then, for matplotlib:
brew install libjpeg
python3 -m pip install matplotlib
This works for me on a Mac min with Apple Silicon.
No luck for SciPy yet, though.

Not able to import matplotlib in spyder

i am new to python, and have installed python version
Python 3.7.3
pip --version
pip 19.1.1 from C:\ProgramData\Anaconda3\lib\site-packages\pip (python 3.7)
the following are my environment variables
pip 19.1.1 from C:\ProgramData\Anaconda3\lib\site-packages\pip
(python 3.7)
C:\Users\lijin\AppData\Local\Programs\Python\Python37-32\
%USERPROFILE%\AppData\Local\Microsoft\WindowsApps
i have installed matplotlib successfully using the command
pip install matplotlib
now, while importing matplotlib in the spyder, i am getting an error
ModuleNotFoundError: No module named 'matplotlib.py'
what am i missing here?

How to install tensorflow-gpu for both python2 and python3

I already have installed tensorflow 1.2, CUDA 8.0 and CuDNN 5.1 for python2.7. Now I want to use it for python3.5 but importing tensorflow fails. How do I install tensorflow for python3 again. And do I have to do the CUDA and CuDNN episodes again?
You can create separate environment for python 2 and 3. Thus, you can easily install corresponding tensorflow versions. Remember you have to install everything separately on virtual environment once cuda and cudnn are installed on your system as per the instructions on Tensorflow webpage: https://www.tensorflow.org/install/install_linux
Although I would preferably keep both the envs separate but I tried to install both the versions in the same environment and it works.
My system configs are - CUDA - 8.0, CuDNN -7.1 and I tried installing Tensorflow 1.4.0.
# First, I created virtualenv for python2 as:
virtualenv --system-site-packages tf3n4 # tf3n4 is env name
# Then, I installed virtualenv for python3 with same name, it will not override python2 but it will create a seperate python3 bin.
virtualenv --system-site-packages -p python3 tf3n4
# go to your env (it's in my home directory)
source ~/tf3n4/bin/activate
Now you can check for both pythons by which python2 and which python3, this will be in your env path but not on the local machine python. For example: I got this /home/USERNAME/tf3n4/bin/python2 and /home/USERNAME/tf3n4/bin/python3.
#Now, install tensorflow for python 2:
python2 -m pip install --upgrade tensorflow-gpu==1.4
# install tensorflow for python 3:
python3 -m pip install --upgrade tensorflow-gpu==1.4
Once, you are done, you can run any python just by mentioning it:
python2 or python3 before running any code on terminal
If you have already installed tensorflow 1.2, CUDA 8.0 and CuDNN 5.1 for python2.7. Then you can:
yum install python3-pip
(now you have python3 and pip3, however the python version may not be 3.5)
python3 -m pip install --upgrade tensorflow-gpu==1.2
(make sure the installed version is exactly same as that of python2)
I made it after these two steps.

Python3.6 is installed but pip3 command not found on Mac os x

I have installed python3.6 and Jupiter Notebooks on my computer using anaconda. Now, I need to install TensorFlow for python3. To show the version of pip: I type these command:
pip -V: pip 9.0.1 from /Users/xxx/anaconda3/lib/python3.6/site-packages (python 3.6).
pip3 -V: command not found.
What I understand is pip pointed to python3.6 and I can use it to install Tensorfolw (it is like a alias to pip3). Is it correct?

Resources