I'm trying to install numpy for python3, and I used sudo apt-get install python3-numpy to install numpy as I use Jetson tx2.
Although the installation is successful, but numpy is installed on python2.7 not python3. How can I solve it?
Actually when you flash your Jetson TX2 with Jetpack (version), numpy package is present for Python2 by default and not for Python3.
In order to install numpy for Python3 Please follow the steps given below:-
1. Check if you have pip3 installed for Python3. If not install pip3.
sudo apt install python3-pip
2. Then using pip3 install numpy
pip3 install numpy
After installation check the location: /usr/local/lib/python3.6/dist-packages you will find numpy installed for Python3 Hope this helps!
I think this is because your default interpreter is Py v2.7
Check this by runnin in console:
python -V
Then you can specify Py3 installation as was commented above:
pip3 install numpy
Note: Do not run this command with sudo because it will run setup.py
with sudo or
in other words - an arbitraty upload a malicious project on PyPI this
is a hight risk action.
You can try using the python3 package manager :
pip3 install --user numpy
I wanted to install the numpy package for python 3.5 on my Mac OS High Sierra, but I can't seem to make it work.
I have it on python2.7, but I would also like to install it for the next versions.
Currently, I have installed python 2.7, python 3.5, and python 3.7.
I tried to install numpy using:
brew install numpy --with-python3 (no error)
sudo port install py35-numpy#1.15.4 (no error)
sudo port install py37-numpy#1.15.4 (no error)
pip3.5 install numpy (gives "Could not find a version that satisfies the requirement numpy (from versions: )
No matching distribution found for numpy" )
I can tell that it is not installed because when I type python3 and then import numpy as np gives "ModuleNotFoundError: No module named 'numpy'"
Any ideas on how to make it work?
Thanks in advance.
First, you need to activate the virtual environment for the version of python you wish to run. After you have done that then just run "pip install numpy" or "pip3 install numpy".
If you used Anaconda to install python then, after activating your environment, type conda install numpy.
If running pip3.5 --version or pip3 --version works, what is the output when you run pip3 freeze? If there is no output, it indicates that there are no packages installed for the Python 3 environment and you should be able to install numpy with pip3 install numpy.
I use Spyder, with Python 2.7, on a windows 10. I was able to install the PyPDF2 package with a conda command from my prompt. I said installation complete. Yet, If I try to run a simple import command:
import PyPDF2
I get the error:
ImportError: No module named PyPDF2
How can I fix this?
In my case, I was trying to import 'pyPdf2' instead of 'PyPDF2'. Observe the case.
import PyPDF2
is correct.
If you use python3 maybe
apt-get install python3-pypdf2
I faced the same problem. But, In my case,
I previously installed Python3 separately from official website and was using without any issues
Then later I installed Anaconda package distribution software which itself has another Python3 installed in corresponding directory.
So, when I installed PyPDF2, it installed normally and while importing throws an error, because the base path of python3 was changed to be used with Anaconda.
Then I opened Anaconda prompt and installed PyPDF2 there and tried to import. It worked!!
Then I can use it from any command prompt in my Windows PC. Or else you can delete Anaconda and everything works normally. Its just a conflict of two pythons in my pc.
Conclusion: Try any overlapping softwares in your PC(in my case Anaconda prompt) and try their CMD to install packages and import. If I wanted to install any package I have to go to Anaconda prompt and install it and importing that modules works anywhere without any error. So from now on wards I'm only using Anaconda prompt as my default installation prompt.
This is the case which I followed for python3. For python2 try with pip:
pip install PyPDF2
I had this problem too when I tried to import PyPDF2 like this:
sudo apt-get install python-pypdf2
When running some simple script with import PyPDF2, I would get an error like this:
ImportError: No module named PyPDF2
The solution was to also install pdfmerge, like this:
pip install pdfmerge
How to install Python packages on Windows, Mac, and Linux for various versions of Python which are simultaneously installed:
I have multiple versions of Python installed on my Windows 8.1 machine (Python 2.7, 3.5, and 3.7). This created problems (confusion, I should say). You must therefore be very explicit when installing packages. Ex:
py -3.7 -m pip install PyPDF2 # on Windows
python3.7 -m pip install PyPDF2 # on Mac and Linux
INSTEAD OF the more generic:
pip install PyPDF2 or
pip3 install PyPDF2
And to upgrade pip, be very specific in your python version, like this:
py -3.7 -m pip install --upgrade pip # on Windows
python3.7 -m pip install --upgrade pip # on Mac and Linux
INSTEAD OF the more generic:
py -3 -m pip install --upgrade pip # on Windows
python3 -m pip install --upgrade pip # on Mac and Linux
Now, I can run python 3.7 with py -3.7 on Windows, or with python3.7 on Linux, and since I did py -3.7 -m pip install PyPDF2 on Windows, or python3.7 -m pip install PyPDF2 on Linux or Mac, the import PyPDF2 command works! Previously, since I had only done pip3 install PyPDF2, the import PyPDF2 command only worked if I ran py -3.5 on Windows or python3.5 on Linux, oddly enough, since apparently that was my "default Python3 version" which the more generic pip3 install PyPDF2 command must have installed the PyPDF2 module into. I think it has something to do with the fact that I installed Python 3.5 for all users, but Python 3.7 for only my user account, so the different pip install commands were placing the installed packages into different locations, with the 3.5 version being the "default" Python3 install location.
See more here: https://docs.python.org/3/installing/index.html:
... work with multiple versions of Python installed in parallel?
On Linux, Mac OS X, and other POSIX systems, use the versioned Python commands in combination with the -m switch to run the appropriate copy of pip:
python2 -m pip install SomePackage # default Python 2
python2.7 -m pip install SomePackage # specifically Python 2.7
python3 -m pip install SomePackage # default Python 3
python3.4 -m pip install SomePackage # specifically Python 3.4
Appropriately versioned pip commands may also be available.
On Windows, use the py Python launcher in combination with the -m switch:
py -2 -m pip install SomePackage # default Python 2
py -2.7 -m pip install SomePackage # specifically Python 2.7
py -3 -m pip install SomePackage # default Python 3
py -3.4 -m pip install SomePackage # specifically Python 3.4
When using pip, it usually gets installed in Python 2+ so try
pip3 install PyPDF2
I had the same issue and fixed it when switching Python compiler (bottom left corner on Visual Studio Code) . Try on different versions and eventually it should work.
Im following a UDEMY course here. Im using Anaconda prompt and jupyter notebook.
I encountered the same issue as OP. What I did to have the library working:
restart the environment
go to your anaconda prompt
control c to stop the running instance
conda activate ***your_env_here***
pip install PyPDF2
(in my case open the jupyer notebook) jupyter notebook
You can now import the library without the error. import PyPDF2
Hope this works for you.
I encountered the same issue today while doing Udemy course.
try the following:
type this
import sys
!{sys.executable} -m pip install PyPDF2
then
import PyPDF2
Hope it works for you too.
I want to install pip for python 2.7, but I am also having python 3.x but both locations are different. when ever I install or update the pip It is installing in the python 3.x location.
How to install pip for python 2.7?
I recently found the following solution, when you are maintaining python2.x and python 3.x in host system. You can find the pip under Scripts folder.
Try pip --version it gives pip version and python version as well
If you want to install package using pip use the following commands.
python -m pip install package_name
python2.x -m pip install package_name
Which reads the specified python pip module to install the package
System: Ubuntu 12.04 (precise)
If I install scikit-learn through
sudo apt-get install python-sklearn
I can import sklearn in python but get version 0.10, which I do not want
If I install scikit-learn through
sudo pip install -U scikit-learn
I can see the scikit_learn-0.14.1-py2.7.egg-info under /usr/local/lib/python2.7/dist-packages/
but I don't know how to get python to import the correct version. Setting PYTHONPATH to /usr/local/lib/python2.7/dist-packages/ did not help.
How do I get python to load the modules from where pip puts them, not where apt-get install puts them?
You can set the site dir in your code.
import site
site.addsitedir('/usr/local/lib/python2.7/dist-packages')
It might be the case that you have several versions of python installed and the pip command in your PATH is not matching the python command in your path. You can check with:
which python
which pip
cat `which pip`