Reputation: 33
I am using Linux subsystem for Windows 10, in which several versions of Python have been installed. The default one, found by typing
which python
in the shell is the one located in
/opt/intel/oneapi/intelpython/latest/bin
, i.e. the default version of Intel OneAPI.
I installed sympy by using the following command:
sudo apt-get install python3-sympy
and the corresponding folder seems to be located in /usr/bin/sympy
.
When I open Python, as I type import sympy
, I get the message
ModuleNotFoundError:No module named 'sympy'
.
Therefore, I would like to make the default version of Python recognize the 'sympy' package.
Finally, I wish to thank for the collaboration in advance.
Upvotes: 3
Views: 1127
Reputation: 16747
APT installs python packages just into default system-wide Python installation.
To install python packages into your specific custom Python installation just do python -m pip install sympy
, here python
is your python's binary name or path, e.g. you can do /path/to/python -m pip install sympy
.
You may need adding sudo
to command to run it as root, i.e. sudo /path/to/python -m pip install sympy
. Or another option is to install packages into user's directory by adding --user
, i.e. /path/to/python -m pip install --user sympy
. Both of these two options will work for you.
Notice! As said in @OscarBenjamin comment it is strongly not adviced to use sudo
(better to use --user
) because pip install
can run any arbitrary code from Internet as root when used with sudo
, see SO answers here. At least don't use sudo
with untrusted pip packages.
Upvotes: 2