I installed matplotlib with package manager in Linux Mint 17.1. When I type import matplotlib in python3 terminal, everything works fine. However, when I create virtualenv, and then I run this command, Python cannot find this module. Can I somehow force my virtual environment to see it is already installed?
Related
I am using Python3.9 on Windows machine. I created a virtual environment (my_venv) and activated it. cd to the my_venv folder and then did pip3 install quandl if I then run pip3 list I can see Quandl3.7.0 in the list.
making sure I am in the my_venv directory I then run Jupyter Notebook and it launches and says the kernel is called python3 (which is the only kernel available). When I then run import quandl I get "No Module named 'quandl'"
Note: I have tried the import with and without a capital Q and in both cases it gives the same error.
Here is the code that I used:
import math
import matplotlib.pyplot as plt
The error message was:
no module named 'matplotlib'
I have tried:
pip install matplotlib
python3 install mat plotlib
Tried updating Anaconda Navigator to the latest version.
Tried uninstalling and reinstalling Python 3.10.5
Tried using Visual Studio Code and individual Python files (I'll try Jupyter too).
conda update --all
python - version says that I have Python version 3.6.13
After all of that, I still get the same error that there is no module named matplotlib
The answer was that I had never actually attempted to access matplotlib outside of Jupyter Notebooks. I was only meant to access it inside of Jupyter. I created a virtual environment and that didn't work. I also did conda install matplotlib and that destroyed my Python install and I had to reinstall everything.
I've tried downloading opencv through pip, conda and downloading whl file from https://www.lfd.uci.edu/~gohlke/pythonlibs/#pygame , no luck so far.
I tried
pip install opencv-contrib-python ,
pip3 install opencv-contrib-python ,
pip install opencv-python,
pip3 install opencv-python
All give same result, after successful installation, I get cv2 installed without an actual cv2.py file inside it, there is a folder CV2 inside site packages, which has looks like bellow:
and receive no module named cv2when asking to import cv2 on Spyder. When I use the ame command in the Python Shell, it imports with no issues and runs cv2.imread also with no issue, so am not quite sure if its a Python or a Spyder issue.
I also used anaconda 3 conda install, there exist issues between h5py package and opencv package, have not been able to download. I use windows 10. Ive tried the method outlined here:
Cannot find module cv2 when using OpenCV
Ive installed, uninstalled and reinstalled python 3.7, Can anyone direct me on any other paths to take?
So I did the following to be able to run import cv2 from Spyder 3 (built in with Anaconda): Uninstall and Reinstall Anaconda 3 and adding it to the PATH. I then copied everything inside the cv2 folder in the python folder (shown in screenshot in original question) and added it to the Scripts Folder in the Anaconda Directory (where it has been downloaded).
My understanding is the issue arised from Spyder not sourcing the Python directory although the interpreter is set as python and the wd set as a subfolder of the python directory (whithin which the cv2 folder exists). Downloading directly from Conda didnt work due to compatibility issues between h5py and opencv. Check if you can import cv2 from Python shell directly, if so its a IDE issue - took me two days to figure it out.
I'm not sure what's going on here. I installed Python with Anaconda, there are no previous versions of Python installed. Everything works fine with Spyder, Jupyter Notebooks, or within Anaconda prompt itself. When I try to run numpy or pandas in cmd, I get an error. When I run them in Anaconda prompt, no issue.
Looks like both prompts are pointing to the exact same installation of Python. I've even ran python.exe from the Anaconda install folder and get the same error.
My Environment Variable path points to C:\Anaconda , where the python.exe is found. Any ideas as to what's going on?
Edit: I noticed I import numpy on the conda screenshot and I'm trying to import numpy on the cmd screenshot. Importing either pandas or numpy on conda loads it successfully.
Edit 2: Opening python.exe within the Anaconda folder gives the same output. Can't import numpy/pandas. Opening Anaconda Navigator -> base (root) -> Open with Python successfully imports numpy/pandas. How can the python.exe within Anaconda not detect libraries installed by Anaconda... yet running Python within Anaconda Navigator works?
Edit 3: SOLVED Ended up uninstalling and reinstalling both Pandas and Numpy through Anaconda prompt. Really odd but now both packages work regardless if I use Conda prompt or cmd.
Try upgrading the pip first and then try to uninstall if they are already present in the below order.
pip uninstall pandas
pip uninstall numpy
pip install pandas
pip install numpy
I am trying to run some code using ortools on a python environment. I did not have troubles on a windows machine but I am having problems on mac (10.12.6). if in my virtual environment I run
pip freeze
or
conda list
ortools appears in my list of installed packages. But if I try to use it
ipython
from ortools.linear_solver import pywrapplp
I get an error saying that there's no module named ortools. If I go to
mac/anaconda3/envs/nameenv/lib/python3.6/site-packages I do have a folder called ortools with some python files including pywrapplp. Do you know what I am doing wrong ?
EDIT
following request from coments:
import os
os.getcwd()
returns '/Users/imac'
which ipython
/anaconda3/bin/ipython
Installing ortools is a bit of a headache. It was some days ago, I think I finally made it with
easy_install ortools
I think it is a problem with the path. I guess because I did not install it with conda it does not find the package. I got around writting:
sys.path.append('/anaconda3/envs/env_name/lib/python3.6/site-packages/')
at the begining of my ipynb. That way I can run ortools.
You could have several python interpreter installed (python2 and python3)
So if you want to use it with ipython, which seems to be bind on python3 in your case.
First check if you have pypi package ortools installed
ipython -m pip show ortools
If you got an error it means the package is not installed.
so you can easily install it using:
ipython -m pip install --user ortools
note: We provide Pypi ortools package (64 bits) for Manylinux, Windows and MacOS.
You can also rebuild it from source https://developers.google.com/optimization/introduction/installing/source