I think since I'm new to python, I installed packages in multiple subversion. like python 2.7.15 or python 2.7.14.
If I import certain package (e.g., hdf5storage) using terminal (python 2.7.15), I can >> import hdf5storage
but if I import the package using jupyter notebook (python 2.7.14), i cannot. >> import hdf5storage
no module called hdf5storage.
I didn't install this different version on purpose, it just happened.
I used pip2 to install packages. Can anyone explain how to solve this issue, for a beginner? How do I use virtualenv or edit PATH, it's very confusing for me. Any answer would be appreciated!
Related
I have installed python3 in my ubuntu 20.04LTS operating system. I have also installed the Jupyter notebook directly from the snap store. Now I am trying to install OpenCV from jupyter notebook using: pip install OpenCV-python.
I have also tried: !pip install OpenCV-python
In both the case it says requirement already satisfied. Below is the screenshot:
Whenever I am trying: import cv2.
It gives error:libGL.so.1: cannot open shared object file: No such file or directory.
Though I have installed OpenCV through the terminal in python3 and it successfully gets imported in python3 terminal. But not able to import in Jupyter notebook.
Please suggest, how can I resolve this issue and import OpenCV to Jupyter Notebook.
Any link where I can learn and understand how these libraries interact with the operating system when installed through python and Jupyter notebooks will be helpful.
Thanking you!
This is happening due to using pre-built CPUs. Install package as headless one.
I had similar issue that got resolved by using below command
pip install opencv-python--headless
reference https://pypi.org/project/opencv-python-headless/
Idk if this is a stackoverflow-appropriate post so forgive if the question is misplaced. I'm trying to install OpenCV into my Pycharm IDE through the conda virtual environment. I typed conda install -c conda-forge opencv inside the PyCharm terminal and it has been doing this for 11 hours and God knows how many more to go.
Pycharm did this with PyTorch as well. Am I doing something wrong or is this normal?
While you can install packages directly in PyCharm by going to file->settings select Project Interpreter and click on the '+' icon on the top right (see image)
I would recommend creating a requirements.txt file in the root of your project, and write down all your required packages. When a package is missing, PyCharm will automatically suggest to install the package for you.
e.g. for installing opencv you can add the following to you requirements.txt
opencv-python
Or even specify the version that your project needs
opencv-python==4.1.2
edit: the advantage of using a requirement.txt is that you can more easily port the project to another machine, and re-install the packages if needed.
I have previously installed python 3.7, anaconda3 and jupyter notebook.
Then I tried to install opencv library using the following command.
pip install opencv-python
and it said,
Requirement already satisfied: opencv-python in c:\programdata\anaconda3\lib\site-packages (4.1.1.26)
When I tried to import open-cv library from IDLE it gives the following error.
ModuleNotFoundError: No module named 'cv2'.
But when I run it from the jupyter notebook it works.
The reason for this as I see is that the packages are installed in the anaconda3 folders but not in the python folders.
How can I install packages in python folders? As I need to run this from the IDLE.
I'm using python 3.7.1 on windows 10.
Thank you.
what IDLE are u using for program in python? If you are using Python IDLE, usually when you import packages, are installed in C:\Users\Your_Username\AppData\Local\Programs\Python\Python37-32\Lib
If you want to install a package in other folder, try to use this
pip install --target=C:\path\to\folder\ opencv-python
If you have another IDLE, put me in the comments what is it (PyCharm, VSCode...).
I am on Windows 10 acer laptop. I have downloaded anaconda2 and use it to download packages. With anaconda2 came a spyder installation with an IPython console option. Using the IPython console I am trying to import packages. However, for some of them I get an ImportError. Spyder Ipython terminal
However when I run conda list I clearly see these packages listed.
openblas Clearly Seen
I think i don't have parse library. So, Where can i get it?
As beginner, I need your help.
I wrote from lxml.html import parse , Computer say name 'parse' is not defined
You actually probably need the lxml package, which was in the comment by cel. It seems to me like your question is concerning how to actually install the package. Everything at PyPi (the Python package index) can be installed in several ways. For me, the easiest is using pip, which is a tool for installing Python packages. Here are some links for how to get pip on your machine for different operating systems: Windows, Mac OSX, or in general.
Once you have pip installed, you go to your command line and type
pip install ['package_name']
where, in your case, package_name would be lxml. Once you do that, your import should work just fine. The full pip documentation is here.
If you prefer to manually install the package, you can download the source and install it according to the Python docs for Python 2.x or 3.x.