Python Path error - No Module Found error - python

I'm having issues running ortools on Linux. I downloaded it from google's site (https://developers.google.com/optimization/) and installed it using "make install," but when I go to use it in python I get the following:
Traceback (most recent call last):
File "regular.py", line 42, in <module>
from ortools.constraint_solver import pywrapcp
File "/home/m3/summer/ortools_examples/examples/python/ortools.py", line 2, in <module>
ImportError: No module named linear_solver
It looks like despite installing ortools, its still not in my python path correctly, so when I call it in the file, it doesn't find anything and returns an error, right? Any advice on how to solve this?

Related

How to change the path where Jupyter looks for libraries

I have python 3.10 installed on disk C: and Anaconda with Python 3.9 on disk D:. When I try importing numpy in jupyter, I get the following error.
>>> import numpy
Traceback (most recent call last):
File "C:\Python310\Lib\site-packages\numpy\core\__init__.py", line 23, in <module>
from . import multiarray
File "C:\Python310\Lib\site-packages\numpy\core\multiarray.py", line 10, in <module>
from . import overrides
File "C:\Python310\Lib\site-packages\numpy\core\overrides.py", line 6, in <module>
from numpy.core._multiarray_umath import (
ModuleNotFoundError: No module named 'numpy.core._multiarray_umath'
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "C:\Python310\Lib\site-packages\numpy\__init__.py", line 140, in <module>
from . import core
File "C:\Python310\Lib\site-packages\numpy\core\__init__.py", line 49, in <module>
raise ImportError(msg)
ImportError:
IMPORTANT: PLEASE READ THIS FOR ADVICE ON HOW TO SOLVE THIS ISSUE!
Importing the numpy C-extensions failed. This error can happen for
many reasons, often due to issues with your setup or how NumPy was
installed.
We have compiled some common reasons and troubleshooting tips at:
https://numpy.org/devdocs/user/troubleshooting-importerror.html
Please note and check the following:
* The Python version is: Python3.9 from "D:\ProgramData\Anaconda3\python.exe"
* The NumPy version is: "1.23.3"
and make sure that they are the versions you expect.
Please carefully study the documentation linked above for further help.
Original error was: No module named 'numpy.core._multiarray_umath'
Looks like Python interpreter from disk D: is looking for libraries in disk C:, and I suppose that the numpy file installed there is not compatible with python 3.9. I think it's because my PYTHONPATH is
>>> print("PYTHONPATH:", os.environ.get('PYTHONPATH'))
PYTHONPATH: C:\Python310\Lib\site-packages
But how do I change it so that Jupyter only looks for what's in Anaconda folder libraries and not break whatever I have on disk C:? I guess what I'm asking is, is it possible to have 2 PYTHONPATHs, one for Jupyter and one for whatever else? Would it be sufficient to just add Anaconda libraries folder to PYTHONPATH, or it would cause conflicts? Because how would Jupyter choose one path over the other?

Pyp3 gives ModuleNotFoundError even if packaged is install

So I'm trying to figure out if I can speed up my code. For that purpose I installed pyp3. But when I try to run the python file using pyp3 I get error in the first line itself ModuleNotFoundError, But when I use simple python my code works smoothly. Is it due to python version difference ? I'm new to pyp3. Any suggestion/help would be appreciated. Thankyou
pypy3 main_feature_extraction.py
Traceback (most recent call last):
File "main_feature_extraction.py", line 1, in <module>
from dotenv import find_dotenv, load_dotenv
ModuleNotFoundError: No module named 'dotenv'

Python igraph import error on Windows

I've installed igraph form .whl file using pip install. When I was trying to test the correctness of installation
import igraph.test
igraph.test.test()
I got this error:
Traceback (most recent call last):
File "D:/Nauka/Praca-inzynierska/Barabasi-Albert.py", line 4, in <module>
import igraph.test
File "D:\Programy\Python 3.5\lib\site-packages\igraph\__init__.py", line 34, in <module>
from igraph._igraph import *
ImportError: No module named 'igraph._igraph'
(the same error pops out if I'm trying to import igraph not igraph.test).
I've tried adding path (I don't know if this is rigth):
import sys
sys.path.append ("D:/Programy/Python 3.5/Lib/site-packages/igraph")
but it didn't work.
One thing I discovered is that if I delete "__init__" file from igraph folder I can import igraph without error, but it doesn't work for igraph.test.
If it's relevant I have Python 2.7 installed on my machine alongside Python 3.5.
Thank you in advance for any help.

Error "ImportError: no module named mux" in Python

I installed a module one month ago. At that time, I could import the module successfully.
Now, when I import this module, there is an ImportError,
>>> import anuga
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/home/lili/anuga_core/source/anuga/__init__.py", line 110, in <module> from anuga.file_conversion.urs2nc import urs2nc
File "/home/lili/anuga_core/source/anuga/file_conversion/urs2nc.py", line 12, in <module>
from mux import WAVEHEIGHT_MUX_LABEL, EAST_VELOCITY_LABEL, \
ImportError: No module named mux
How could I solve this problem?
ImportError comes only when the module is not available in the list called sys.path. Since the current operating system is Linux based (I got an idea from the error message /home/lili), it is required to have mux.py in the path (i.e, sys.path). The mux.py file will be exactly similar to the file available in this link.
`https://anuga.anu.edu.au/svn/anuga/trunk/anuga_core/source/anuga/file/mux.py`
All these problems come when the installation of ANUGA is not proper.

ImportError: couldn't find library

I am encountering these errors frequently when I install python libraries and I'm wondering what I am doing wrong
the current example is the libchromaprint library
http://acoustid.org/chromaprint
I install it and everything, try to run the python example, get:
Traceback (most recent call last):
File "examples/fpwav.py", line 7, in <module>
import chromaprint
File "build/bdist.linux-x86_64/egg/chromaprint/__init__.py", line 24, in <module>
ImportError: couldn't find libchromaprint
and then when I check:
find /usr/local/lib/libch*
/usr/local/lib/libchromaprint.so
/usr/local/lib/libchromaprint.so.0
/usr/local/lib/libchromaprint.so.0.1.3
what am I doing wrong?
Python does not use your usual library path. The chromaprint you're looking for should be somewhere like /usr/lib/pymodules/python2.6.
From the python interpreter do:
>>> import sys
>>> sys.path
This will show you the directories python searches for a module.

Categories

Resources