So recently I cloned a repository SymPy by doing the following steps:

  • Created Python3 virtual environment
  • Activated it (from Terminal)
  • Then ran git clone _sample_URL_

After that I ran the following to open up IDLE:

$ python -m idlelib

Then I ran the following commands:

>>> import sympy

No error, but after that I ran the following to import a module as given in this documentation:

from sympy.abc import x, y

it gives the following error:

Traceback (most recent call last):
  File "<pyshell#8>", line 1, in <module>
    from sympy.abc import x, y
ImportError: No module named 'sympy.abc'

Any idea what am I doing wrong here?

  • Can you check that the sympy you are importing is the one you expect? Try import sympy then sympy.__file__ and sympy.__version__ – match Apr 7 '19 at 20:13
  • @match I'll try it tomorrow... But what do you mean by 'the one you expect' . Are you suggesting that it is importing from the main global python sympy? (Don't know the correct term) – DuttaA Apr 7 '19 at 20:19
  • Yes - to check that the sympy you are importing is the git cloned one and not a system-wide one. – match Apr 7 '19 at 20:23
  • @match but would it matter? I mean I don't expect it to be very different (in terms of version) so shouldn't it import fine? – DuttaA Apr 7 '19 at 20:28
  • @match i ran the commands in IDLE shell. It is saying no attribute in sympy named file and no attribute in sympy named version. – DuttaA Apr 8 '19 at 7:18

It's likely that you are importing a sympy other than the one you intended.

You can debug which sympy you are importing using sympy.__file__ and sympy.__version__ which should give you more information on which one you are using, and help debug things.

If that doesn't work it might also be worth checking that the git repo has the appropriate files you'd expect in sympy/ (e.g. abc/ etc).

Alternatively if you aren't concerned with using the latest code form github, just do pip install sympy instead to get the latest version into your virtual environment.

| improve this answer | |
  • I don't know whether you have developed using git or not but if you have can you answer a question? I downloaded sympy inside it was setup.Py and another sympy, now when I imported that another sympy by copy paste in another venv it ran fine, but for the current venv I had to run setup.py and everything went smoothly from there. My question is now if I write some new module and push it in GitHub will it be identical to the original? Or does anything change after running setup.py? – DuttaA Apr 8 '19 at 15:57
  • It all comes down to what setup.py contains - usually it is just enough to tell pip how to build and install a package - however it can also contain any arbitrary python code, so you need to read what else it does other than it's main setup method. – match Apr 9 '19 at 14:20

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.