Panda 3D Python import error on OSX - python

I have been messing around with Python/Panda3D and trying to get my first file to run. I am on OSX and after installing Panda3D I tried to run this file:
import direct.directbase.DirectStart
run()
That was followed by this on the Terminal output:
$ python core.py
Traceback (most recent call last):
File "core.py", line 2, in <module>
import direct.directbase.DirectStart
ImportError: No module named direct.directbase.DirectStart
I have been searching everywhere, but all the forms don't really solve the problem. Any help would be awesome!
Thanks!

This is usually a problem when you're using a version of Python other than the one Panda3D is compiled with. If you are using the 1.9.0 Lion build of Panda3D, make sure you are using the system-provided copy of Python 2.7, by explicitly running "python2.7" or "ppython" (which should be a symlink to the correct version of Python).

Related

Linux terminal and Python are mushed together

When I run some commands, which work, for example neofetch, it gives me a Python error.
username#host:~$ as
Traceback (most recent call last):
File "/usr/lib/command-not-found", line 28, in <module>
from CommandNotFound import CommandNotFound
File "/usr/lib/python3/dist-packages/CommandNotFound/CommandNotFound.py", line 19, in <module>
from CommandNotFound.db.db import SqliteDatabase
File "/usr/lib/python3/dist-packages/CommandNotFound/db/db.py", line 5, in <module>
import apt_pkg
ModuleNotFoundError: No module named 'apt_pkg'
It does that whenever I type an invalid command. This started happening after I installed Python 3.9. I am running Kubuntu with Python 3.10 installed by default.
Modern Linux distributions tend to use a lot of python scripts for internal use; for this reason python gets installed with a plethora of libraries.
The error you are getting is because you replaced that fairly complete system python with a version of your own choosing without providing all the libraries the original came with.
The error you see is emitted by /usr/lib/command-not-found, a script using python3 as found in the system path.
I strongly recommend that you re-install the original python packages and use e.g. anaconda for your specific python needs.
The main takeaway from this is:
DON'T MESS WITH THE SYSTEM PYTHON.
try to find which python are you using using which python and uninstall the first python interpreter it finds.

ModuleNotFoundError, even after pip install

I have recently bought a new laptop and was viewing some python projects of mine which I made on my pc. For one of them I use the python-bitvavo-api library which I installed using pip3 install python-bitvavo-api. The version I installed is 1.2.2 which is the latest on their website.
Now when I try to import it using this code: from python_bitvavo_api.bitvavo import Bitvavo, I get the following error:
Traceback (most recent call last):
File "C:\Users\indig\OneDrive\Documenten\Python Projects\Personal\Cryptone\Cryptone.py", line 6, in <module>
from python_bitvavo_api.bitvavo import Bitvavo
ModuleNotFoundError: No module named 'python_bitvavo_api'
I read online that it may occur when using multiple python versions, Im only using 1 and thats python 3.7
Btw. I have the same error with the Pillow module, so it might be a setting in visual studio that I dont know of. Anyway, someone please help. If you need more details please ask.
How are you running it? From the terminal or from VS?
You can also check the installed libraries running the command pip list

ImportError: No module named operator

I'm rather new to using python and haven't done really anything to configure python. my professor gave us an autograder.py file that checks our python code for correctness. the autograder.py file imports a file called grader.py which then imports something known as cgi (import cgi). inside this cgi file located at '/usr/lib/python2.7/cgi.py' there is a line of code that says
from operator import attrgetter
this is where the problem occurs. i recieve the following error
Traceback (most recent call last):
File "autograder.py", line 12, in <module>
import grading
File "/home/ggkfox/Documents/164-CSCI/1-Assignment/tutorial/grading.py", line 13, in <module>
import cgi
File "/usr/lib/python2.7/cgi.py", line 37, in <module>
from operator import attrgetter
ImportError: No module named operator
it is my understanding that the operator module should be built in (according to other stack overflow posts). this error only occurs when i use python2.7.12 (as opposed to python3.5). i have had a simular issue importing Tkinter in 2.7 aswell.
also i want to say that i have tried uninstalling python using:
sudo apt-get purge python2.7
but it wont even uninstall for me to even attempt to reinstall. im not using any pipenv or desktopenv.
i dont know what else to say, im very new to python coding.
It is almost a necessity to use a virtualenv for each python project.
A virtualenv creates a dedicated python environment and it saves you from a lot of 'operating system' related issues.
Here, you can find some virtualenv solutions compatible with all Python versions, along with the official python 3.6.4 documentation.

Error while importing igraph

I am using Python 3.6 on Windows 7 and I have a problem with the igraph package. I was having errors while I was trying to install it using pip, so I decided to install it from the .whl file. Unfortunately, I couldn't find version appropriate for Python 3.6, so I downloaded another version and changed the name of the file so that it looked like it was designed for Python 3.6. The installation was successful, but when I am trying to run a script which uses the igraph module - a following error message appears:
Traceback (most recent call last):
File "C:/Users/Jarek/Documents/Studia/Programowanie/Python na studiach/Analysis of Unstructured Data/List2.py", line 6, in <module>
import igraph as ig
File "C:\Users\Jarek\AppData\Local\Programs\Python\Python36-32\lib\site-packages\igraph\__init__.py", line 34, in <module>
from igraph._igraph import *
ModuleNotFoundError: No module named 'igraph._igraph'
I haw a very similar issue under Python igraph import error on Windows
but there was no answer there. I have also seen
No module named 'igraph._igraph' but suggestion given there does not help me (or I do not know how to properly apply it).
Any help will be greatly appreciated. Thanks in advance.
I couldn't find version appropriate for Python 3.6, so I downloaded another version and changed the name of the file so that it looked like it was designed for Python 3.6.
So the trick didn't work. Use Python 2.6 or 2.7. Or compile from sources.

Trying to download modules but python can't find them

So I need some modules for a project and after trying a lot of things and googling a lot of things I still can't get it to work. I used this code to test if the module was working:
import sys
sys.path.append('c:\users\my name\anaconda2\lib\site-packages')
import numpy
x = randn(100,100)
And I got this error:
Traceback (most recent call last):
File "C:\Users\My Name\Desktop\test.py", line 3, in
import numpy
ImportError: No module named numpy
Any idea why I'm doing wrong?
You can try two things:
1) which python
And see what python you are using. You may be still pointing to old python the system has. In that case add ~/anaconda2/bin to $PATH environment variable.
2) sys.path.append('c:\users\my_name\anaconda2\lib\python2.x\site-packages')
Usually anaconda library is installed under lib\pythonx.x(the correct python version number)\site-packages. So change that.
If none of the above worked, then just do clean install from scratch all over again.

Categories

Resources