Installing Octave Symbolic Package using SymPy (macOS) - Can't get SymPy to work - anaconda

So, I've installed the Octave Symbolic Package from here:
https://sourceforge.net/p/octave/symbolic/ci/master/tree/
In the Octave command window I typed:
pkg install -forge symbolic
After the install I ran a test (as shown in link above) by typing:
pkg load symbolic
syms x
However, I got an following error with syms x.
Symbolic pkg v2.8.0: Traceback (most recent call last):
File "<string>", line 1, in <module>
ImportError: No module named sympy
error: Python cannot import SymPy: have you installed SymPy?
Try "sympref diagnose" for more information.
error: called from
assert_have_python_and_sympy at line 123 column 7
python_ipc_popen2 at line 79 column 5
python_ipc_driver at line 59 column 13
python_cmd at line 163 column 9
valid_sym_assumptions at line 38 column 10
assumptions at line 82 column 7
syms at line 97 column 13
Next, I visited the following site to install SymPy (which says to install Anaconda).
https://docs.sympy.org/latest/install.html#anaconda
So, then I go to the following site and download the graphical installer for macOS (Python 2.7 version).
https://www.anaconda.com/distribution/#download-section
Then I tested from the macOS terminal to see if Anaconda is installed using this command
conda --version
which returns conda 4.7.11.
I also typed
conda list
which returns (among a long list). sympy 1.4 py27_0.
So, it appears that SymPy is installed (at least at the terminal).
Next, I go back to the command line of Octave and typed:
sympref diagnose
Here is the output:
Symbolic package diagnostics
============================
Python and SymPy are needed for most features of the Symbolic package.
The Python interpreter is currently: "python".
Computers may have more than one Python interpreter installed. If you
need to, you can select a different one using the PYTHON environment
variable (see "help sympref"). For example, to use Python 3, try
setenv PYTHON python3
sympref reset
Attempting to run python -c "print(\"Python says hello\")"
status = 0
output = Python says hello
Good, Python ran correctly.
Python version
--------------
Let's check what version of Python we are calling...
Attempting to run python -c "import sys; print(sys.version)"
status = 0
output = 2.7.15 (default, Feb 5 2019, 12:31:36)
[GCC 4.2.1 Compatible Apple LLVM 8.0.0 (clang-800.0.42.1)]
SymPy Python Library
--------------------
SymPy is a Python library used by Symbolic for almost all features.
Attempting to run python -c "import sympy; print(sympy.__version__)"
Traceback (most recent call last):
File "<string>", line 1, in <module>
ImportError: No module named sympy
status = 1
output =
Unfortunately status was non-zero: probably Python cannot import sympy.
* Is there an error message above?
* Do you have SymPy installed? If not, please try to install it and
try again.
* If you do have SymPy installed, maybe it's installed for a different
Python interpreter than the one we found? Please try "setenv" as
described above to change your python interpreter.
Octave doesn't have access to SymPy.
Any idea what I did wrong?

Try running these in octave...
setenv PYTHON /usr/local/anaconda3/bin/python
pkg load symbolic
/usr/local/anaconda3/bin was where all my anaconda bits were installed,
including a version of python. Yours may differ.
sympref diagnose then passes for me.
You will have to do this every time you start 'octave' before using the symbolic package, but it should be safe.

Related

Version of pip package diamond can't be called, neither by --version nor by other packages

I need the pip package 'diamond' as a prerequisite for another package (humann3), however something doesn't work.
When I try to start humann3 it returns
CRITICAL ERROR: Can not call software version for diamond
So I try to check my diamond version with "diamond --version" but it returns
user#server:~$ diamond --version File
"/home/user/.local/bin/diamond", line 113
print "Diamond version %s" % (get_diamond_version())
^
SyntaxError: invalid syntax
It's supposed to be version 4.0.515, I just uninstalled it and reinstalled it. No change.
The OS is Debian GNU/Linux 10 (buster), it's my college's computer, I can't change it. But I have permission to install and unistall packages.
Also I realized that if I use different python versions to run it directly, I get different errors.
Python 3 returns the same error:
(base) user#server:~$ python3 .local/bin/diamond
File ".local/bin/diamond", line 113
print "Diamond version %s" % (get_diamond_version())
^
SyntaxError: invalid syntax
Python 2 returns another one:
(base) user#server:~$ python2 .local/bin/diamond
Traceback (most recent call last):
File ".local/bin/diamond", line 24, in <module>
from diamond.server import Server
ImportError: No module named diamond.server
Python 3 returns the same error:
(base) user#server:~$ python3 .local/bin/diamond
File ".local/bin/diamond", line 113
print "Diamond version %s" % (get_diamond_version())
^
SyntaxError: invalid syntax
The code print "" is for Python 2 only, in Python 3 it is SyntaxError. The problem was fixed in the Github repository but the code was not released to PyPI. To us it under Python 3 you need to install it from Github. First install git if you haven't installed it yet and the run
pip install -U git+https://github.com/python-diamond/Diamond.git
Python 2 returns another one:
(base) user#server:~$ python2 .local/bin/diamond
Traceback (most recent call last):
File ".local/bin/diamond", line 24, in <module>
from diamond.server import Server
ImportError: No module named diamond.server
You've installed the module only for Python 3, you cannot run it under Python 2. To run it under Python 2 you need to install it with Python 2:
python2 -m pip install -U diamond
But then you will also need to install everything (including humann3) under Python 2.

Python 3.9 import issue

I just installed Python 3.9 with the Windows 64-bit installer. For some reason the all of the modules I had previously installed using pip will no longer import, unless I am running Python from the directory where they are located: C:\Users\<user>\AppData\Local\Programs\Python\Python38-32\Lib\site-packages
I tried uninstalling/reinstalling the requests module with pip and then importing requests in a shell, still not recognized.
>>> import requests
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
ModuleNotFoundError: No module named 'requests'
I imagine this is probably some environmental variable path issue. I'm new to Python, any help getting this straightened out much appreciated.
Each version of python has its own global sites package directory where it stores the packages you install.
Ex: Python 3.8 will store under %appdata%\Local\Programs\Python\Python38-32\Lib\site-packages
Python 3.9 would store it in a different location (like Python39-32)
In order to install a package for specific version of python you need to install it with python version command.
py -3.9 -m pip install requests
You can refer the official documentation here

Scipy installation windows 10

I have some difficulties trying to install Scipy for Python 3.5 on a Windows 10 machine and I hope I can find some help here. So here is what I have done so far.
I have downloaded the numpy+mkl for python 3.5 and 64bit version as well as the scipy0.18.1 for the same versions, from Gohlke's website
I installed the numpy+mkl whl with:
python -m pip install numpy-1.11.2+mkl-cp35-cp35m-win_amd64.whl
all goes well.
then I install the scipy package the same way like:
python -m pip install scipy-0.18.1-cp35-cp35m-win_amd64.whl
This also completes.
However, when I try to run python afterwards I get the following error:
Fatal Python error: Py_Initialize: can't initialize sys standard streams
Traceback (most recent call last):
File "C:\Python35\Lib\site-packages\scipy\io\__init__.py" , line 97, in <module>
File "C:\Python35\Lib\site-packages\scipy\io\matlab\__init__.py", line 13 in <module>
File "C:\Python35\Lib\site-packages\scipy\io\matlab\mio.py", line 8 in <module>
ImportError: No module named 'numpy'
I also get a pop-up that Python has stopped working.
I have tried a different order in which I installed the packages, but all lead to the error mentioned when Scipy is installed.
I also installed did this on a windows 7 machine and there it works.
Does anybody have any idea what causes this issue?
I also had some issues. So I just installed Anaconda3 insted of python directly.

TypeError when downloading rapidsms using pip in django-tables2

I'm a total python newbie. I installed python 3.3.1 on a 32 bit windows 7 professional. I'm trying to install RapidSMS, and it should be as easy as "pip install rapidsms" and it does start the process, but it doesn't complete and I'm left with the below error message.
I've been trying to google it, but I haven't been able to find this specific problem, for the error I find fixes for people who have written the code themselves, and I haven't seen anyone mention this problem about rapidsms themselves. Since it stops in Django-tables, I wonder if I messed up that installation somehow or if there's a problem with the python version compatibility. I've used pip when installing some other software, so I don't think that's the problem.
So if anyone's encountered this error when installing pyhton packages or really have any idea what the cause might be I'd really appreciate it! (I also plan to post this in the RapidSMS mailing list when I get approved, but wanted to see if this was a more general problem that might have a fix.)
Downloading/unpacking django-tables2==0.13.0 (from rapidsms)
Running setup.py egg_info for package django-tables2
Traceback (most recent call last):
File "<string>", line 16, in <module>
File "c:\users\mhealth1\appdata\local\temp\pip-build-mhealth1\django-tables2\setup.py", line 7, in <module>
version = re.search('__version__ = "(.+?)"', f.read()).group(1)
File "C:\Python33\lib\re.py", line 161, in search
return _compile(pattern, flags).search(string)
TypeError: can't use a string pattern on a bytes-like object
Complete output from command python setup.py egg_info:
Traceback (most recent call last):
File "<string>", line 16, in <module>
File "c:\users\mhealth1\appdata\local\temp\pip-build-mhealth1\django-tables2\setup.py", line 7, in <module>
version = re.search('__version__ = "(.+?)"', f.read()).group(1)
File "C:\Python33\lib\re.py", line 161, in search
return _compile(pattern, flags).search(string)
TypeError: can't use a string pattern on a bytes-like object
----------------------------------------
Command python setup.py egg_info failed with error code 1 in c:\users\mhealth1\a
ppdata\local\temp\pip-build-mhealth1\django-tables2
Storing complete log in C:\Users\mhealth1\pip\pip.log
Django-tables2 fails to install in Python3 because of the following code from line 7 of setup.py in the traceback:
version = re.search('__version__ = "(.+?)"', f.read()).group(1)
This should work if the search pattern was a bytes object. A byte literal can be created by simply pre-pending the string literal with a b like the following:
version = re.search(b'__version__ = "(.+?)"', f.read()).group(1)
This is why Python is throwing a TypeError with the message "Can't use a string pattern on a bytes-like object". The file contents are being read in as bytes.
I don't think RapidSMS currently supports Python3 yet based on its list of environments that are tested. This can be seen in the tox environments list of the project seen here, in which only Python 2.6 and 2.7 are listed: https://github.com/rapidsms/rapidsms/blob/develop/tox.ini#L2
To solve the immediate problem, you'll want to install RapidSMS in a virtual environment with Python 2.6 or 2.7. The documentation for RapidSMS describes virtual environment setup briefly here: http://www.rapidsms.org/en/develop/topics/virtualenv.html
You'll want to install Python 2.6 or 2.7 on your system and specify which Python for the virtualenv to use, using the -p or --python argument. The following is taken from the RapidSMS docs linked above, but ammended to specify using Python 2.7:
mkvirtualenv --distribute --no-site-packages rapidsms --python=python2.7

I can't import igraph on mac 10.6

I installed igraph for python in my mac but I can't import it. First I installed C core library, then I proceeded with the instalation for python, by doing:
python setup.py build
python setup.py install
Everything seemed to work fine but I can't import igraph from python shell. Just to clear up, I'm not inside igraph source code's folder. And I got this error:
import igraph
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "build/bdist.macosx-10.3-fat/egg/igraph/__init__.py", line 30, in <module>
File "build/bdist.macosx-10.3-fat/egg/igraph/core.py", line 7, in <module>
File "build/bdist.macosx-10.3-fat/egg/igraph/core.py", line 6, in __bootstrap__
ImportError: dlopen(/Users/*****/.python-eggs/python_igraph-0.5.4-py2.7-macosx-10.3-fat.egg-tmp/igraph/core.so, 2): Symbol not found: _igraph_vector_destroy
Referenced from: /Users/*****/.python-eggs/python_igraph-0.5.4-py2.7-macosx-10.3-fat.egg-tmp/igraph/core.so
Expected in: dynamic lookup
I replaced my folder's name for *, so don't consider it.
I'm running python 2.7 over OS 10.6.7. So there's no pre-compiled version of igraph avaliable (2.5 and 2.6 only). Has this error anything to do with the python version I'm running?
If possible, how can I work this out?
I think the problem is that igraph is installed in /usr/local/lib/libigraph.dylib, but the linker cannot find it when Python tries to load the C core of the igraph module because /usr/local/lib is not on the default library path in Mac OS X. (At least I think so).
First, please check whether libigraph.dylib is really in /usr/local/lib - it should be there. After that, try this:
DYLD_LIBRARY_PATH=/usr/local/lib python -m igraph.test.__init__
This should instruct the linker to look around in /usr/local/lib as well as the default places, and then run Python with the entire igraph test suite.

Resources