ImportError: No module named haystack - aptana

If I install the latest stable 1.2.7 django-haystack with sudo pip install django-haystack, it works fine. But after uninstalling it and installing the very latest dev version 2.0.0 BETA instead as suggested on the main page:
pip install -e git+https://github.com/toastdriven/django-haystack.git#master#egg=django-haystack
Despite the success messages below, it seems like it is not properly installed:
Obtaining django-haystack from git+https://github.com/toastdriven/django-haystack.git#master#egg=django-haystack
Cloning https://github.com/toastdriven/django-haystack.git (to master) to ./src/django-haystack
Running setup.py egg_info for package django-haystack
Installing collected packages: django-haystack
Running setup.py develop for django-haystack
Checking .pth file support in /usr/local/lib/python2.7/dist-packages/
/usr/bin/python -E -c pass
TEST PASSED: /usr/local/lib/python2.7/dist-packages/ appears to support .pth files
Creating /usr/local/lib/python2.7/dist-packages/django-haystack.egg-link (link to .)
Adding django-haystack 2.0.0-beta to easy-install.pth file
Installed /home/kave/projects/cb/src/django-haystack
Successfully installed django-haystack
Cleaning up...
because when I go into the django shell environment and do a
>>> from haystack import indexes
Traceback (most recent call last):
File "<console>", line 1, in <module>
ImportError: No module named haystack
I have followed the instructions and have
INSTALLED_APPS = (... 'haystack',) in there
I had this problem before, but could never solve it. sudo pip install default works fine, but as long as I get the latest Git version, my django doesn't seem to see it.
What could I be missing?
Many Thanks for your advice,
UPDATE
Apologies, but it seems the error is happening only within Aptana Studio 3.0. In Django Shell I can do the import after all. I am still dazzled, as this should be the same. Why can Aptana see the libraries when installing with sudo pip install django-haystack but not if using latest Git version? What could go wrong there please?
UPDATE 2
full sys.path
['/home/kaveh/projects/cb', '/usr/local/lib/python2.7/dist-packages/requests-0.13.9-py2.7.egg', '/home/kaveh/projects/cb/src/django-haystack', '/usr/lib/python2.7', '/usr/lib/python2.7/plat-linux2', '/usr/lib/python2.7/lib-tk', '/usr/lib/python2.7/lib-old', '/usr/lib/python2.7/lib-dynload', '/usr/local/lib/python2.7/dist-packages', '/usr/lib/python2.7/dist-packages', '/usr/lib/python2.7/dist-packages/PIL', '/usr/lib/python2.7/dist-packages/gst-0.10', '/usr/lib/python2.7/dist-packages/gtk-2.0', '/usr/lib/python2.7/dist-packages/ubuntu-sso-client', '/usr/lib/python2.7/dist-packages/ubuntuone-client', '/usr/lib/python2.7/dist-packages/ubuntuone-control-panel', '/usr/lib/python2.7/dist-packages/ubuntuone-couch', '/usr/lib/python2.7/dist-packages/ubuntuone-installer', '/usr/lib/python2.7/dist-packages/ubuntuone-storage-protocol']

I finally got it working.
As I said the problem is pip install -e git+https://github.com/toastdriven/django-haystack.git#master#egg=django-haystack is apparently not working.
I simply uninstalled it and made sure its deleted.
Then I simply downloaded the source as zip file, extracted it and
python setup.py build
sudo python setup.py install
This way it will guaranteed be working. Hope this helps someone.

Related

libgssapi_krb5.so.2: undefined symbol: k5_sname_compare in while importing PyQt6.QtWebEngineWidgets [duplicate]

After installing anaconda3, I began to install pyside2.
I directly typed pip install pyside2, and successfully installed pyside2 5.15. But when I ran the toy example, an error occurred:
Traceback (most recent call last):
File "test.py", line 2, in <module>
from PySide2.QtWidgets import QApplication, QLabel
ImportError: /usr/lib/x86_64-linux-gnu/libgssapi_krb5.so.2: symbol krb5_ser_context_init version krb5_3_MIT not defined in file libkrb5.so.3 with link time reference
I when to /usr/lib/x86_64-linux-gnu and found both libgssapi_krb5.so.2 and libkrb5.so.3, and I have no idea how to fix this bug. Can anybody help me?
My environment:
python: 3.8.3
OS: ubuntu 18.04
CPU: AMD ryzen 3600
You are getting the error because you have a wrong version of qt on your machine. I mean it seems anaconda installs the wrong version of QT by default. First, you need to install essential packages (enter link description here) and then do the following steps:
pip uninstall pyside2, qt, pyqt5 if you have installed them with pip
conda remove pyside2, qt, pyqt5 if you have installed them with conda
conda install -c conda-forge pyside2
I had a similar issue, though I was not using anaconda. The error appears to be a krb5 version mismatch between PySide2 and Ubuntu packages. I was able to resolve the issue by compiling krb5 from source and adding the lib directory to LD_LIBRARY_PATH.
tar xf krb5-1.18.2.tar.gz
cd krb5-1.18.2/src
./configure --prefix=/opt/krb5/
make && make install
export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:/opt/krb5/lib
python -c "import PySide2.QtCore"
The python import no longer raised an error. I found this worked with several different krb5 versions from the offical website; the error seems to be in the Ubuntu modifcations to the package.
You may have success with uninstalling and reinstalling the Python Qt bindings, as suggested by the other answers, but this did not work for me.
Just build in the pyside2 dependencies. if you wanna to use your virtual environment.
End build the Clang Library
I am sorry, your answer above seems correct except for the presence of opencv, which is not in the original question. Opencv in my opinion has nothing to do with pyside2 or the question. So, the correct procedure in my opinion would be:
1. pip uninstall pyside2, qt, pyqt5 if you have installed them with pip
2. conda remove pyside2, qt, pyqt5 if you have installed them with conda
3. conda install -c conda-forge pyside2

Python packages required to run RStudio Quarto files in VS Code

I have been trying to run RStudio Quarto script in a fresh Ubuntu 20.04 installation but got into some trouble. Some Python packages that are required to run the simple hello.qmd were not there. I was getting these errors:
MoudleNotFoundError: No module named 'nbclient'
and a second error:
ModuleNotFoundError: No module named 'matplotlib_inline'
The first error was due to I had install the nbclient package. My default Python installation is python2.7. Quarto will not run well with Python 2.7; we should try with 3.7+. If your Linux doesn't come with it by default, this can easily be addressed by installing another Python version and configuring multiple Python versions with the help of the command:
sudo update-alternatives --config python
If no Python version shows up, then it means you have first to configure all your installed Python versions. This is very well explained at https://www.rosehosting.com/blog/how-to-install-and-switch-python-versions-on-ubuntu-20-04/
Once you have configured all your Python versions, every time that you run
sudo update-alternatives --config python, you will be prompted to enter the Python version you want as default. If you have a fresh Ubuntu 20.04, most likely that you have two: Python 2.7 and Python 3.8. Select 3.8 and you will fine. Quarto won't work with Python 2.7.
After you have python3 running and switched into, install nbclient with:
pip install nbclient.
The first error will now pass, but most likely you will get now
ModuleNotFoundError: No module named 'matplotlib_inline'. This is because you also need to install the package matplotlib-inline. This is not documented in the installation instructions of Quarto. But easy to fix. Run:
pip install matplotlib-inline
Now, go back to your VS Code, open the command palette and run Quarto: Render, or just type from the terminal:
quarto preview hello.qmd --no-browser --no-watch-inputs
You are done!

SQLMAP missing one or more core extensions ('gzip', 'ssl', 'sqlite3', 'zlib')

How to solve the following problem?
[16:49:39] [CRITICAL] missing one or more core extensions ('gzip', 'ssl', 'sqlite3', 'zlib') most likely because current version of Python has been built without appropriate dev packages
I had the same problem, basically you need to install the dev packages of those extensions and then reinstall Python.
In my case I was missing the bz2 and I installed it using this command:
sudo apt-get install libbz2-dev
Then I reinstalled python3 using:
pyenv install 3.8.0
And that solved the problem. In your case you'll need to install all those packages (and their dev counterparts) and reinstall Python.

App Deployment: Django not installing on server- AttributeError: 'module' object has no attribute 'lru_cache'

I am trying to deploy a Django App and for some reason, I keep getting this error. It seems to me that Django is not installed but it also errors when installing. Thank you for the help on this. I am deploying on Amazon EC2
(venv) ubuntu#ip----:~/quotes$ pip install Django
Collecting Django
Using cached Django-2.0.tar.gz
Complete output from command python setup.py egg_info:
Traceback (most recent call last):
File "", line 1, in
File "/tmp/pip-build-ceP6se/Django/setup.py", line 32, in
version = __import__('django').get_version()
File "django/__init__.py", line 1, in
from django.utils.version import get_version
File "django/utils/version.py", line 61, in
#functools.lru_cache()
AttributeError: 'module' object has no attribute 'lru_cache'
----------------------------------------
Command "python setup.py egg_info" failed with error code 1 in /tmp/pip-build-ceP6se/Django/
Django has stopped its support for Python 2 version, still you can try installing 1.11 version by using the below code.
pip install Django==1.11
According to the django 2.0 release notes, The Django 1.11.x series is the last to support Python 2.7 (Check it here)
So you can choose to use an older version of Django and then install it with this command:
pip install 'Django<2'
but if you decided to buildup your project using Django>=2.0 then you should create a virtual environment with python 3.4 or higher this way:
sudo apt-get update
sudo apt-get install python3 python3-pip
sudo -H pip3 install virtualenv
mkdir ~/myproject
cd ~/myproject
virtualenv -p `which python3` myprojectenv
source ~/myproject/myprojectenv/bin/activate
python -V
it should output something like this:
Python 3.X.Y
Now you are able to install the latest version of Django without any error:
pip install Django
Good luck,

DistributionNotFound error after upgrading pip

In reading about virtualenv here I realized I didn't have pip 1.3+, so I ran pip install --upgrade pip and now when I run pip --version i get the following:
Traceback (most recent call last):
File "/usr/local/bin/pip", line 5, in <module>
from pkg_resources import load_entry_point
File "/usr/local/Cellar/python/2.7.3/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/distribute-0.6.34-py2.7.egg/pkg_resources.py", line 2807, in <module>
parse_requirements(__requires__), Environment()
File "/usr/local/Cellar/python/2.7.3/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/distribute-0.6.34-py2.7.egg/pkg_resources.py", line 594, in resolve
raise DistributionNotFound(req)
pkg_resources.DistributionNotFound: pip==1.2.1
If it helps, or is at all relevant, my $PATH looks like this:
/usr/local/bin:/usr/local/share/python:/usr/bin:/bin:/usr/sbin:/sbin:/usr/local/bin:/usr/local/git/bin
Also, which pip gives me /usr/local/bin/pip.
Not sure what to do about the error. Thanks.
The brutal way:
Assuming you are using homebrew for Mac (because I see /usr/local/Cellar), I suggest to
remove (or backup) /usr/local/lib/python2.7, and
brew rm python && brew install python.
This will definitely install pip 1.3.3 alongside of python. Your distribute will also be 0.6.35.
The soft way:
From /usr/local/lib/python2.7/site-packages just remove:
easy-install.pth
pip-1.2.1-py2.7.egg or other versions of pip you have.
distribute-0.6.34-py2.7.egg or other versions
Then, brew rm python && brew install python. This will leave all your other bindings from brew and installed stuff intact. Python, pip and distribute will be replaced with up-to-date versions.
additionally:
Please check that you don't have a distribute or setuptools or pip located in /Library/Python/2.7/site-packages. That dir is re-used by all python 2.7 versions (brewed or from OS X) and will interferre with the pip/distribute already installed by Homebrew.
I happened to get to a similar state after upgrading from OS X Lion to Mountain Lion today.
The other proposed solutions either do not work, or replace the Apple version of Python with the brew version, which I'm not sure is what saclark asked for.
What I did to get it fixed is install distribute manually, thus getting easy_install back to work, and then install pip with it.
The commands are:
$ curl -O http://pypi.python.org/packages/source/d/distribute/distribute-0.6.45.tar.gz
$ tar -xzvf distribute-0.6.45.tar.gz
$ cd distribute-0.6.45
$ sudo python setup.py install
$ sudo easy_install pip
If the link does not work, you can alway find newer versions of distribute here.
I got similar problem today. After some research, I solved it by reinstalling pip using this:-
python -m pip install --upgrade --force-reinstall pip
Hope somebody would find it helpful.
As an aside, there's an easier way to do it (I just encountered this).
Edit /usr/local/bin/pip and change the references to version number (so below you'd want to change '1.5.6' to whatever version number you're using):
#!/usr/local/opt/python/bin/python2.7
# EASY-INSTALL-ENTRY-SCRIPT: 'pip==1.5.6','console_scripts','pip'
__requires__ = 'pip==1.5.6'
import sys
from pkg_resources import load_entry_point
if __name__ == '__main__':
sys.exit(
load_entry_point('pip==1.5.6', 'console_scripts', 'pip')()
)
then you may be completely good at that point.
I wanna find out at where pip 1.2.1 is required, but I don't have so much time... so I just downgrade pip to 1.2.1. It can't be helped for a while, till pip or distribute package is modified.
How to do this? just type this in console(I hope your distribute package is well):
easy_install pip==1.2.1
There is no need to uninstall python and install it back. Get the latest distribute package installed and then update pip with it should do the trick.
wget https://bitbucket.org/pypa/setuptools/raw/bootstrap/ez_setup.py
sudo python ez_setup.py
sudo easy_install -U pip
The correct way to fix modern version (6.x) of pip in 2 steps
Delete the pip package in Python's site-package. For Homebrew Python 2.7, do this:
rm -r /usr/local/lib/python2.7/site-packages/pip
Follow the instructions on the official pip documentation site to reinstall it. For short:
curl -O https://bootstrap.pypa.io/get-pip.py
python get-pip.py
For pip 6.x, there's no need to install the legacy distribute package. Just setuptools, which will be installed by default via the get-pip.py script mentioned above.
Hm.. puzzling. Wonder where that 1.2.1 comes from. Just out of curiosity, could you post the contents of /usr/local/bin/pip? Should only be a couple of lines.
You could try updating pip (again) with distribute, and maybe also distribute itself..
easy_install --upgrade distribute
easy_install --upgrade pip

Resources