I am trying to import some libs, including:
from past.builtins import xrange
problem is, I keep getting this error:
ModuleNotFoundError: No module named 'past'
I've successfully installed and upgraded future, both localy AND on my virtualenv:
C:\Users\JON>pip install future
C:\Users\JON>pip install --upgrade future
(.env) C:\Users\JON>pip install future
(.env) C:\Users\JON>pip install --upgrade future
still, when I run this import on Jupyter I get the error above.
I should mention I'm using Windows 10 and Anaconda+Jupyter for python 3.6
Anybody has an idea why this happens and how to fix it?
Related
My IDE is Spyder and the distribution I am using is miniconda. I use pip install in the anaconda prompt window (as I usually do).
'pip install xls2xlsx' seems to run fine and install the package.
When I try 'from xls2xlsx import XLS2XLSX' I get the following error:
ModuleNotFoundError: No module named 'currency-symbols'
If I try 'pip install currency-symbols' , I get:
'Requirement already satisfied: currency-symbols in c:\users\user\miniconda3\lib\site-packages (2.0.2) '
I can see both directories in the site-packages directory.
So I had the same or very similar problem, my trace-back said it could not import currency_symbols. I found that the module it was trying to import was the constants from that package. So I went into the py file where xls2xlsx had the issue
"htmlxls2xlsx.py" my traceback said line 40..
currency_symbols_constants =
importlib.import_module('currency-symbols.constants')
I noticed this was part of an 'exception' so I fixed line 37 from import currency_symbols.constants as currency_symbols_constants to import currency_symbols._constants as currency_symbols_constants
Now it imports just fine.
I also had version 2.0.2 of currency-symbols installed, but my working host was using 2.0.1. I discovered that if you install 2.0.1, the issue did not occur.
pip3 install -Iv currency-symbols==2.0.1
I am new to python and was using a python script written by someone else. I was running it fine in a different PC. Just had to install coupe of packages including pip3, google-cloud, google-cloud-bigquery and pandas.
Now when I installed the same packages on a different PC, I am unable to run the script. It is showed the following error first:
module = 'google.protobuf.descriptor_pb2' TypeError: expected bytes, Descriptor found
However, when In purged/re-installed/updated packages and also added protobuf3 and protobuf-py3 package, The error has been updated to the following message:
from google.cloud import bigquery
File "/home/mobeen/.local/lib/python3.6/site-packages/google/cloud/bigquery/__init__.py", line 35, in <module>
from google.cloud.bigquery.client import Client
File "/home/mobeen/.local/lib/python3.6/site-packages/google/cloud/bigquery/client.py", line 50, in <module>
import google.cloud._helpers
File "/home/mobeen/.local/lib/python3.6/site-packages/google/cloud/_helpers.py", line 33, in <module>
from google.protobuf import duration_pb2
File "/home/mobeen/.local/lib/python3.6/site-packages/google/protobuf/duration_pb2.py", line 8, in <module>
from google.protobuf import symbol_database as _symbol_database
File "/home/mobeen/.local/lib/python3.6/site-packages/google/protobuf/symbol_database.py", line 193, in <module>
_DEFAULT = SymbolDatabase(pool=descriptor_pool.Default())
AttributeError: module 'google.protobuf.descriptor_pool' has no attribute 'Default'
.Any help or leads in this will be appreciated
I solved the problem by uninstalling protobuf:
pip3 uninstall protobuf
pip3 uninstall python3-protobuf
NB: You should repeat this command until you get a message that there is no package named protobuf.
After that execute:
pip3 install protobuf
Install just the protobuf , don't install python3-protobuf
Hope this solution can help you.
I solved it by first executing twice
pip3 uninstall protobuf
The second time the terminal returned
Found existing installation: protobuf 3.6.1
Not uninstalling protobuf at /usr/lib/python3/dist-packages, outside environment /usr
Can't uninstall 'protobuf'. No files were found to uninstall.
Then I removed protobuf manually
sudo rm -r /usr/lib/python3/dist-packages/google/protobuf*
sudo rm -r /usr/lib/python3/dist-packages/protobuf*
And finally I executed
pip3 install --upgrade protobuf
And the problem was solved
Did you try this too?
"I solved the problem of showed Attribute Error: 'module' object has no attribute 'Default' when import tensorflow after installed by delete redundant protobuf file.
The reason is some google/protobuf/descriptor_pool.py do not have a 'Default' defined. This usually happened at old version of protobuf so I upgraded successfully, but problem not solved. And by checking PATH and search about 'google/protobuf', I found it existed in both "/usr/local/lib/python2.7/dist-packages/google/protobuf/" and "/usr/lib/python2.7/dist-packages/google/protobuf/". Previous one have attribute 'Default' but the second one not.
I tried import google.protobuf and google.protobuf.file, It shows '/usr/lib/python2.7/dist-packages/google/protobuf/init.pyc'. I deleted /usr/lib/python2.7/dist-packages/google/protobuf and tried to import tensorflow, worked."
Actually I've ran into a similar case, we had 2 packages installed protobuf and python3-protobuf. I actually dont know the root cause for this but apparently when you do that:
pip install protobuf
pip install python3-protobuf
that error you described is happening, looks like it gives you some different version, like those two packages have overlapping files, and they override each other or something.
the solution for me was simply to reverse the installation order (make sure to uninstall them both first):
pip install python3-protobuf
pip install protobuf
or just
pip install python3-protobuf protobuf
hope this helps anyone here.
The reason can be that the interpreter that you are using to run the python programm uses the previous version of google.protobuf
You can assure it to run in the interpreter
>>> import google.protobuf
>>> print google.protobuf.__version__
Then compare it running in the terminal
$pip show protobuf
If the versions are different that's the reason
So I suggest deleting this package right from the python interpreter console
>>> pip uninstall protobuf -y
After you can even install the package right from the python console
>>> pip install protobuf
After that you good to go ✌️
I am getting ImportError: No module named _pluggy error when running tests using pytest.
Then I tried installing pluggy using pip install pluggy. It installs pluggy==0.6.0 successfully, but is still giving the error.
Versions List (From running pip freeze | grep pytest)
pytest==3.3.1
pytest-cov==2.5.1
pytest-metadata==1.5.0
pytest-runner==3.0
pluggy==0.6.0
Python 2.7.12
Shown below is the stack trace
Tests run successfully when run in a virtualenv. What are the possible causes which can cause this error in a non-virtualenv environment?
As it was pointed out by #bouteillebleu the issue was in pytest-metadata package.
The solution was to upgrade the package
pip install --upgrade pytest-metadata
I'm trying to install IPython notebook on OS X 10.10.2.
After all dependencies have been added, this error occurs:
File "/Library/Python/2.7/site-packages/jinja2/tests.py", line 14, in <module>
from jinja2._compat import text_type, string_types, integer_types
ImportError: cannot import name integer_types
How can I fix this?
How are you installing ipython?
If you have pip, are you using pip install ipython[all]?
I also recommend using virtualenv to start with a completely clean python2.7 install from scratch and see if you encounter the errors still. There may be some version compatibility conflicts on the system.
Alternative is you can install the Anaconda distribution which comes prepackaged with ipython and dependencies http://continuum.io/downloads
Trying to install OpenCV and running into an issue where attempting to import cv2 results in this output -
RuntimeError: module compiled against API version 9 but this version of numpy is 7
Traceback (most recent call last):
File "<pyshell#4>", line 1, in <module>
import cv2
ImportError: numpy.core.multiarray failed to import
I'm running on Windows 7 x64, Python v 2.7.9
Thanks!
The error is telling you that you have an out of date version of numpy. If you used pip to install things you can simply run pip install numpy -U, or download the appropriate version from their website.
In case
pip install -U numpy
doesn't work (even with sudo), you may want to make sure you're using the right version of numpy. I had the same "numpy.core.multiarray failed to import" issue, but it was because I had 1.6 installed for the version of Python I was using, even though I kept installing 1.8 and assumed it was installing in the right directory.
I found the bad numpy version by using the following command in my Mac terminal:
python -c "import numpy;print numpy.version;print numpy.file";
This command gave me the version and location of numpy that I was using (turned out it was 1.6.2). I went to this location and manually replaced it with the numpy folder for 1.8, which resolved my "numpy.core.multiarray failed to import" issue. Hopefully someone finds this useful!
I had a similar problem and I solved it by downgrading my numpy version.
What I did was:
pip install opencv-python
pip uninstall numpy
pip install numpy=1.18
This has worked for me using
Python 3.7
opencv-python 4.4.0.46
numpy 1.18.0
linux: sudo apt-get install python-numpy
if you are using ubuntu bionic beaver then try running: sudo apt-get install python-numpy
had the same issue, resolve by running the above command.
Hope it helps
In your environment you can try this command:
conda uninstall numpy
conda install -c conda-forge numpy
I use Python 3.7 # RPI 4.
For opencv to install properly I had to install the listed libraries below.
(Not every package was actually installed, after request)
Regarding Numpy, I think one should stick to the latest version.
For me what worked is to uninstall the existing version 1.16.2 and stick with the current stable 1.21.2.
Stackoverflow topic at missing libraries here: ImportError: libcblas.so.3: cannot open shared object file: No such file or directory.