After following the Ubuntu/Debian installation instructions for the Nest simulator I can only import the nest module in python2.x, not python3.x
$ python3
Python 3.6.8 (default, Aug 20 2019, 17:12:48)
[GCC 8.3.0] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import nest
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/nest/lib/python2.7/site-packages/nest/__init__.py", line 26, in <module>
from . import ll_api # noqa
File "/nest/lib/python2.7/site-packages/nest/ll_api.py", line 72, in <module>
from . import pynestkernel as kernel # noqa
ImportError: dynamic module does not define module export function (PyInit_pynestkernel)
The default install compiles with the default Python version which is still 2 in Ubuntu.
To use Python 3, run:
cmake -Dwith-python=3 -DCMAKE_INSTALL_PREFIX:PATH=</install/path> </path/to/NEST/src>
Mentioned here in the doc.
NB: don't forget to clear the build folder to avoid issues
Related
While trying to do simulation in the Scientific Linux, I met the following error.
$ python plot_distribt.py
Loaded libmkl_rt.so for dgesvd
Loaded libmkl_rt.so for zgesvd
Traceback (most recent call last):
File "plot_distribt.py", line 32, in <module>
from mps.mps import iMPS
File "/work/wangb/DMRG/mps/mps.py", line 13, in <module>
from algorithms.linalg import np_conserved as npc
File "/work/wangb/DMRG/algorithms/linalg/np_conserved.py", line 294, in <module>
from algorithms.linalg import npc_helper
File "__init__.pxd", line 164, in init npc_helper
ValueError: numpy.dtype has the wrong size, try recompiling. Expected 88, got 96
After creating a virtual environment, I was able to upgrade packages via pip2 install --upgrade numpy --user python, and now I have numpy-1.16.6, scipy-1.2.3 and pandas-0.24.2. However, the above ValueError still occurred.
I have also checked that after opening python within the newly-created environment, I get
Python 2.7.18 |Anaconda, Inc.| (default, Apr 23 2020, 22:42:48)
[GCC 7.3.0] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> import numpy
>>> numpy.version.version
'1.7.1'
>>> numpy.__file__
'/usr/lib64/python2.7/site-packages/numpy/__init__.pyc'
>>>
Thus, the key might be how to avoid using the numpy-1.7.1? Note that I cannot change anything in /usr/lib64/python2.7/site-packages as I am using the cluster systems from our university.
Thanks a lot in advance!
Python 3.6.9 (default, Apr 18 2020, 01:56:04)
[GCC 8.4.0] on linux
Type "help", "copyright", "credits" or "license" for more information.
> import pandas
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/home/suman/.local/lib/python3.6/site-packages/pandas/__init__.py", line 180, in <module>
import pandas.testing
File "/home/suman/.local/lib/python3.6/site-packages/pandas/testing.py", line 5, in <module>
from pandas._testing import (
File "pandas/src/testing.pyx", line 4, in init pandas._testing (pandas/src/testing.c:4068)
File "/home/suman/.local/lib/python3.6/site-packages/pandas/types/missing.py", line 5, in <module>
from pandas import lib
File "pandas/lib.pyx", line 1, in init pandas.lib (pandas/lib.c:87552)
File "pandas/tslib.pyx", line 67, in init pandas.tslib (pandas/tslib.c:109851)
ImportError: cannot import name parse_date
Make sure that you have installed pandas in the proper directiry:
pip install pandas
If you have already done so, it would be worth upgrading pandas:
pip install pandas --upgrade
Hi I got the same error today when I developed a pyqt project. I found there are two "pandas" when I uninstalled one then tried to install again. What I have done was uninstalling both two "pandas", then install the latest version, then it works. Although I solved this on Windows, but hope it is helpful to you.
ModuleNotFoundError: No module named '_curses' error is seen when running an ansible playbook. Do I need to pip install some particular module?
File "/path/python/lib/python3.7/site-packages/ansible/plugins/action/pause.py", line 41, in <module>
import curses
File "/path/python/lib/python3.7/curses/__init__.py", line 13, in <module>
from _curses import *
Another example of the error:
Python 3.7.0
[GCC 7.3.0] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import curses
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/path/python3/lib/python3.7/curses/__init__.py", line 13, in <module>
from _curses import *
ModuleNotFoundError: No module named '_curses'
>>>
This error is seen because curses was not installed in the system at the time of compiling Python3 sources. Therefore the solution is as follows:
First, install curses:
sudo apt-get install libncurses-dev
sudo apt-get install libncursesw5-dev
(I didn't pay attention on libncursesw5-dev and it may be redundant if libncurses-dev installs it)
Then, build Python from sources.
Python 3.7.0
[GCC 7.3.0] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import curses
No error now, and Ansible playbook runs!
The aiohttp module was installed successfully
But can not be imported as below info
[root#ceph_admin ~]# python3
Python 3.6.5 (default, Jul 1 2018, 23:52:30)
[GCC 4.8.5 20150623 (Red Hat 4.8.5-11)] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import aiohttp
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/usr/local/lib/python3.6/site-packages/aiohttp/__init__.py", line 6, in <module>
from .client import * # noqa
File "/usr/local/lib/python3.6/site-packages/aiohttp/client.py", line 17, in <module>
from . import client_exceptions, client_reqrep
File "/usr/local/lib/python3.6/site-packages/aiohttp/client_reqrep.py", line 17, in <module>
from . import hdrs, helpers, http, multipart, payload
File "/usr/local/lib/python3.6/site-packages/aiohttp/helpers.py", line 40, in <module>
import idna_ssl
File "/usr/local/lib/python3.6/site-packages/idna_ssl.py", line 1, in <module>
import ssl
File "/usr/local/lib/python3.6/ssl.py", line 101, in <module>
import _ssl # if we can't import it, let the error propagate
ModuleNotFoundError: No module named '_ssl'
The error above is
ModuleNotFoundError: No module named '_ssl'
So the real problem is my python3 can not import the module _ssl
My python 3.5 was installed from source code. Below are the correct ways to make python 3.5 have _ssl.
1. install openssl-devel by yum(My OS is CentOS)
2. compile your python source code with command (./configure && make && make install)
So the issue is that apparently Django uses the sqlite3 that is included with python, I have sqlite3 on my computer and it works fine on its own. I have tried many things to fix this and have not found a solution yet.
Please let me know how I can fix this issue so that I can use Django on my computer.
:~$ python
Python 3.5.2 (default, Nov 6 2016, 14:10:16)
[GCC 6.2.0 20161005] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import sqlite3
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/usr/local/lib/python3.5/sqlite3/__init__.py", line 23, in <module>
from sqlite3.dbapi2 import *
File "/usr/local/lib/python3.5/sqlite3/dbapi2.py", line 27, in <module>
from _sqlite3 import *
ImportError: No module named '_sqlite3'
>>> exit()
I figured out that this error was caused by me changing my python path to 3.5 from the default of 2.7.