WinPython Spyder can't see spyder-kernels in virtual environment - virtualenv

I have installed WinPython and want to use Spyder. I use pip and virtual environments. I have followed the instructions here modular approach. Everything works just dandy until the very last instruction "Start a new IPython console (in Spyder). All packages installed in your venv environment should be available there.".
It get error Your Python environment or installation doesn't have the spyder‑kernels module or the right version of it installed (>= 1.9.0 and < 1.10.0). Without this module is not possible for Spyder to create a console for you.
But I installed spyder-kernals in my venv, I can literally see them there, I set the path the the python installed in the venv, everything should work, but it doesn't!
Any thoughts?

I asked CAM Gerlach as suggested, and he spotted my error very quickly. The instructions at modular approach are correct except they say pip install spyder-kernels==0.* which I took literally. In fact as per the error message you need to use later versions, so I used pip install spyder-kernels==1.10 and it fixed it.

You may have to ask to "C.A.M. Gerlach" if he has an update on the procedure: Spyder has evolved a bit with Spyder-4.

Related

How to install pybluez in a Python virtual environment?

I'm wondering how to install pybluez library in a Python virtual environment (Linux Ubuntu / Pop! OS).
The problem is simple: there's no bluetooth.h header in the virtual environment, so it fails during installation.
In real environment there's a series of libraries to install to do the work, but I'm unable to do the same in a virtual environment.
You will need to have the bluetooth.h file and the bluez development files available on the system at all (headers and system libraries are never in virtualenvs anyway).
On Ubuntu, apt install libbluetooth-dev should probably do the trick.
I want to ask to myself cause the problem was really singular and I think that someone else could be involved: the problem is that PyCharm IDE was installed through flatpack. So (I don't know the details cause I'm not an expert about this package format) the program run in a sort of vm and it's unable to recognize libraries under the "real" system. Imho this kind of software (ide I mean) should be inatalled directly with a "classic".deb package to avoid problems like this.

How do I install the hg-git plugin on Debian Stretch?

Debian Jessie, as well as sid, have a mercurial-git package which contains the hg-git plugin. However, this package was (auto-)removed from Debian Stretch to to a release-critical bug.
But - I need it installed and running. Surely this should be possible, right?
Well, I followed the installation instructions on the plugin page:
I ran apt-get install python-setuptools python-setuptools-git python4-setuptools python3-setuptools-git
I ran easy_install hg-git and it seemed to work
But still, when I run various mercurial operations I get, as the first line, the error message:
*** failed to import extension hgext.git: No module named git
(regardless of whether I'm doing anything git-related or not.)
My questions:
Why is this happening?
What do I need to do in order to make the error message go away while having hggit working?
Now,
How do I correctly install dulwich to get hg-git working on Windows?
Apparently, that critical bug doesn't manifest always (and perhaps only under very specific circumstances), so you can try installing the Debian sid version of the mercurial-git package (that is, version 0.8.11-1 at the time of writing). There's a SuperUser question about how to do this:
https://linuxaria.com/howto/how-to-install-a-single-package-from-debian-sid-or-debian-testing
my personal opinion in this case is to simply install the .deb file, which you can get from here (it's not platform-specific; at the link you'll need to choose a mirror.) That makes the error message go away, at least assuming you have:
[extensions]
hgext.bookmarks =
hggit =
in your ~/.hgrc file.

Packages missing from new install of Canopy Express

I just installed Canopy Express 1.4.1 (32-bit) for Windows. Among the packages that are supposed to be there (see https://www.enthought.com/products/canopy/package-index/ ) are pandas and statsmodels. But after installing, neither is listed in Package Manager, either as being installed or available.
The lack of pandas is not a problem, as pip easily installs it. (Enthought notes that packages installed that way will not be listed in Package Manager, but are fully available in the Canopy User Environment. Indeed, it imports.
statsmodels is not so easy. pip only gets source, and there is no Windows installer provided by the statsmodels folks. There is a nightly Windows binary, but not (if I'm reading correctly) for the stable build. The suggested solution by statsmodels is to compile it, using MinGW, which I do not currently have installed.
With enough trouble, I imagine I could compile and install, but is there a way to save all that trouble and get the packages within Canopy, as Enthought says it should be?
Seems like your Package Manager is misbehaving or you are looking in the wrong place (look in Free Packages not Community Packages).
Pandas is indeed in the Express installer, so always installed. At Canopy's python prompt, type:
import pandas
Though sounds like you've already overwritten it with pip, not really a problem but not the cleanest path (mixing 2 different installation methods for the same package).
Statsmodels is listed in package manager (Free package). It is available to free users but is not yet in the Express installer.
If you still don't see these in the pkg mgr, please quit Canopy, ensure that all Canopy processes have terminated (easiest way... log out of Windows, then back in), and restart Canopy.

Python with openCV on MAC crashes

My final goal is to use Python scripts with SciPy, NumPy, Theano and openCV libraries to write code for a machine learning application. Everything worked so far apart from the openCV.
I am trying to install openCV 2.4.8 to use in Python projects in my Eclipse Kepler installation on my MBA running Mac OSX 10.9.2. I have the PyDef plugin v2.7 and a installation of Anaconda v1.9.1.
Here is what I did to install opencv:
sudo port selfupdate
sudo port upgrade outdated
sudo port install opencv
Then I realized that I can't use it that way in Python and did another:
sudo port install opencv +python27
Ok, then I had another Python installation and I added it to my PYTHONPATH in Eclipse>Preferences>PyDev>Interpreter-Python>Libraries.
Before the installation I got an error in the line import cv2, and everything else looked promising. Now this error disappeared but I get other errors when using any functions or variables of cv2. For example I get two errors in this line: cv2.cvtColor(image, cv2.COLOR_RGB2BGR)
Also Python crashes and has to be restarted when I run a simple test program which worked fine before.
With this PYTHONPATH everything works but I have no openCV:
/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7
/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/plat-darwin
/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/plat-mac
/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/plat-mac/lib-scriptpackages
/System/Library/Frameworks/Python.framework/Versions/2.7/Extras/lib/python
/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/lib-tk
/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/lib-dynload
/System/Library/Frameworks/Python.framework/Versions/2.7/Extras/lib/python/pyObjC
/Library/Python/2.7/site-packages/
/Users/xxx/anaconda/lib/python2.7/site-packages
When I add this new folder to the PYTHONPATH...
/opt/local/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages
... openCV seems to work but I have the crashes and the other issue described above.
So, can anyone tell me what the problem is and what I can do to make this work?
Thanks for reading this so far and any help/hint you can provide! Please don't be too harsh, I am, as you can probably easily see just a beginner.
Ok, it's working now. Here is what I did:
Install Python and every package I need for it with Macports
Set the Macports version as standard
Adjust PATH and PYTHONPATH
Reboot (not sure if needed)
Remove old interpreter and libs in Eclipse
Choose the new Python installation as Interpreter in Eclipse
Confirm the new libs in Eclipse
Restart Eclipse
Done

Symbol not found: _PQbackendPID with Django project

Running on MAC os 10.6.8
with postgresSQL installed, as well django - using python2.7
Also installed psycopg2 and dj-database-url using pip in my virtual env
And added these two lines to my setting.py:
import dj_database_url
DATABASES = {'default': dj_database_url.config(default='postgres://localhost')}
Based on instructions for Heroku in:
https://devcenter.heroku.com/articles/django#database_settings
When running:
python manage.py runserver
I am getting this error:
ImportError: dlopen(/Users.... venv/lib/python2.7/site-packages/psycopg2/_psycopg.so, 2): Symbol not found: _PQbackendPID
Referenced from: /Users.... venv/lib/python2.7/site-packages/psycopg2/_psycopg.so
Expected in: dynamic lookup
I kept searching for hours and tried all kind of thing including the advice on:
Mac OS X Lion Psycopg2: Symbol not found: _PQbackendPID
to no avail.
Wonder if anyone had such an issue and had any luck.
I had the same problem. Instead of installing the dependencies as Heroku suggests using
pip install Django psycopg2 dj-database-url
clone whatever repo you're hoping to run in venv, keeping its original settings.py. Then:
source venv/bin/activate
to activate the new environment, cd into your new repo, and python manage.py runserver. Should be set.
Alternatively, you could remake PostGreSQL, and run again, but that's a bit more of a task - it would work for psycopg2, though. As far as I can tell that issue comes from using an 64 or i386 build when you should be using a 32 build - but I'm not sure about this, and the above solution works well to solve the problem and use venv for what you're actually going to be using it for, most likely.
I had the same problem as you guys and I had read many pages and I couldn't find the answer in any of them. Many solution was about installing from source file and don't relate to the virtual environment.
I've found and tested following solution and it solve my problem.
1- Make sure your Postgres is NOT higher than 9.4 version according to psycopg2. Check python version as well. I use Postgres 3.9.9.
2- The problem is behind different version of Python(32/64 bit). It should comply with your operation system's bit architecture which is 64bit. Uninstall all versions of Python and pip from your system. Instruction you can find here but do NOT remove Python2.7 which is Apple-supplied system Python.
3- Install "Mac OS X 64-bit/32-bit" installer from python official website and install it.
After that install pip. Note that you should use the command "python3.5" for using Python version 3.5. You might install virtualenv from the new pip as well.
4- After all that you can go on your virtualenv and type "pip3 install -r requirement.txt" for installing all dependencies on your local machine.
Hope this can help you.