ImportError: No module named sympy - import

I am getting the following error while trying to run a sympy file in order to contribute to sympy. It is :
ImportError: No module named sympy
I installed the sympy module through pip for both python2.7 and python 3.
Also, isympy is working.
Strangly, when I try to import sympy in python's interactive console in the main sympy directory, no import errors are shown but in some other directory, it shows import errors.
Please help me to download the sympy module in a way that I will be able to run the code.
Thanks.
Importing module in python console of main directory.
Importing module in some other directory.

A likely cause here is that you are using two different Pythons. If you have Python installed multiple times (like Python 2 and Python 3), each has its own separate packages. You can check what Python you are using by printing sys.executable.
I should point out that for the purposes of contributing to SymPy, you generally want to run against the development version. That is, running Python from the SymPy directory and importing the development version from there, without actually installing it.

Thanks for the reply.
But I solved the problem. I realised that I didn't install sympy in the current conda environment. When I tried it using the command:
conda install sympy
It worked and no error is being shown.
Thanks.

Related

Orange3 model load in python

I made model.pkcls in Orange3-3.32.0 GUI mode.
I want to load the model.pkcls created by Orange3 in Jupyter Notebook Python.
I ran Jupyter Notebook as administrator to install the Orange3 module.
!pip install Orange3
!pip3 install Orange3-Associate
import Orange
import pickle
model = pickle.load(open('model.pkcls', 'rb'))
To load model.pkcls created in Orange3. But I get an error called ModuleNotFoundError: No module named 'orangecontrib.text'
Before, I had a error ModuleNotFoundError: No module named 'orangecontrib'.
Then I found this. So I did !pip3 install Orange3-Associate.
And when I run it, I got this problem. No matter how much I search, I don't see this error. In this case, how to solve it? Or is there another way to load the model?

Jupyter cant run shapely.geometry

Hey so I've managed to get shapely.geometry to run just fine on PyCharm.
But the difficulty here is in getting the import to run on Jupyter notebook.
I have done:
import geopandas as gpd
This returns shapely.geometry doesn't exist.
I think I know how to fix this through downloading the file
"Shapely-1.6.4.post1-cp37-cp37m-win_amd64.whl" and doing conda install (that)... but it returned that the channel didnt exist...
So I did:
conda install --add channels https://www.lfd.uci.edu/~gohlke/pythonlibs/
(which is where I got the file from) which worked just fine so I then again did "conda install Shapely-1.6.4.post1-cp37-cp37m-win_amd64.whl" but it returned:
CondaHTTPError: HTTP 000 CONNECTION FAILED for url <https://www.lfd.uci.edu/~gohlke/pythonlibs/win-64/repodata.json>
A simple retry will get you on your way...
Tried that, didnt work. Someone please help. Reminder that I successfully installed shapely with all of its modules working through "pip install Shapely-1.6.4.post1-cp37-cp37m-win_amd64.whl" WITHIN Pycharm itself.
EDIT 1
Im following the textbook "Mastering Geospatial Anlsysis with Python" It got me to download the packages:
gdal
geos
shapely
fiona
pyshp
pyproj
rasterio
geopandas
EDIT 2
I dont know what i did but somehow i fixed it... but the thing is, i literally did nothing except take out a shapely file with a long name and kept the one just called "shapely".
If i have files like this
gdal-2.2.2-py36hcebd033_1
instead of this
gdal
Is that the problem?????? because if it is, then i dont know how to get files like that they just either appear or they dont.
Shapely is a wrapper of C++ library called GEOS that is not installed with the wheel. You should go to the page and install that library.
Or perhaps you have Pycharm for python 2 and Jupyter for python 3 (or vice-versa).
Running conda install -c conda-forge geos=3.7.1 worked for me.

How to import a Cython Module into IPython Notebook and compile it

I am using IPython and Cython.
I am editing my Cython functions in modules in an external text editor.
I would like to import these modules and use them in IPython, but with IPython compiling them when importing.
What is the syntax for doing this? I do not want my code inside my IPython notebooks.
This is an unusual workflow but it should be possible to get something working. Firstly, for things to be importable in your IPython session, they must appear in sys.path. You can insert new folders in that list like this:
The path you would be adding would be the folder(s) in which your compiled Cython modules would be placed. Whichever of the next strategies you use, at a minimum the path to your compiled (.pyd) Cython modules needs to be on sys.path to be able to be imported.
Secondly, you need a way to compile your Cython modules. If you're using the recommended approach, you would have a setup.py file with your cython sources and python setup.py build_ext to produce the compiled .pyd files. You would have to restart your IPython Kernel every time you recompiled your Cython modules.
There are alternatives to setup.py. One of them is my easycython which is a command-line tool that compiles .pyx source into .pyd without needing a setup.py. This tool is AFAIK only used/tested by me, so it may not work, ymmv etc. You would still have to restart your IPython Kernel every time you recompiled your Cython modules. (I mention it here only because it is one of my babies.)
A better approach would be to use pyximport, because it will compile on demand and has reload support:
# This is inside your IPython Notebook
import pyximport
pyximport.install(reload_support=True)
import my_cython_module
You can reload the module with
reload(my_cython_module)
You could try to be clever with some kind of logic to make it so that simply rerunning the notebook will either reload or import:
# Speculative code: I have not tried this!
# This is inside your IPython Notebook
import pyximport
pyximport.install(reload_support=True)
if 'my_cython_module' in dir(): # Maybe sys.modules is better?
reload(my_cython_module)
else:
import my_cython_module
You may have to play around a bit to find something that works, but something should be workable for your use-case.

Unresolved reference error when importing basic modules on Pycharm 4.0.1 and OS X Yosemite 10.10.1

After upgrading PyCharm to version 4.0.1 and OS X Yosemite to version 10.10.1, I encountered the following problem:
When trying to import basic modules, e.g: import time or import sys, PyCharm marks the import as an "Unresolved reference" (red underline) and does not recognise the module name.
When trying to figure it out, I noticed that while writing the module name the auto completion pop up is finding a match on the 'lib-dynload' folder within my virtualenv path (/Users/myname/Envs/envname/lib/python2.7/lib-dynload) rather than on the 'site-packages' folder.
There are also added to the PYTHOPATH in this order (lib-dynload before site-packages).
As a workaround I removed the lib-dynload path from the "project interpreter" setting window in PyCharm which made PyCharm recognise the basic modules again, but I am not sure what other impacts this change might have.
My Question is whether there is a way to reproduce the original behaviour PyCharm had so it would recognise the basic modules without tampering the paths of the virtualenv used as a project interpreter.
I am using a separate installation of Python (/usr/local/Cellar/python/2.7.6/bin/python) and virtualenv version 1.10.1.
I'm using pycharm 4.0.1 and virtualenv 1.11.6 and everything works fine to me, but i'm on Arch Linux not OSX.
You may try to recreate the virtualenv, and invalidate and restart the pycharm cache, then wait for pycharm to index again your virtualenv.
Don't know if this is too much of a hassle to you, maybe it is worth a try.
This is a django project tree i tried:
This is probably a bug, a recent youtrack issue seems to match your problem.

needed python packages for ipython

I have recently installed ipython and have before that installed curses:
jinja2 numpy pexpect pygments qt sqlite3 tornado zmq
I have run iptest just after and got OK at the end. But near the end of the report there was the following:
Tools and libraries NOT available at test time:
azure cython matplotlib oct2py pymongo rpy2 wx wx.aui
My question is whether those listed as not available at test time need to be installed for ipython to run optimally?
Thanks.
Question have already been asked and answerd on ML by other users :
http://python.6.n6.nabble.com/IPython-User-question-about-need-td5006172.html
Here is the answer given by MinRK:
No, but some tests of compatibility or extensions, etc. use those, so it's just a note to tell which tests were run.