0

Please help me - I have spent few days reading forums to fix that issue (No success so far).

I still get this error

import PySide.QtCore
ModuleNotFoundError: No module named 'PySide' 

(using Mac OR using my raspberry pi)

Traceback (most recent call last):

File "/Users/macbookair/Documents/Python/Learning Python Chapter Files/chapter4-turtle.py", line 3, in <module>
from PySide.QtCore import *
ModuleNotFoundError: No module named 'PySide'

I have python3 installed. I have installed PySide using several different commands such as

sudo apt-get install python-pyside
sudo apt-get install python3-pyside
sudo apt-get install python3 python3-pyqt5

in the Mac tried

brew install python3  #This worked
brew install qt5 . #This worked - qt 5.9.1 is already installed

Some people say the problem is on the path, so I have tried (I have Python 3.6.1 (v3.6.1:69c0db5050, Mar 21 2017, 01:21:04))

export DYLD_LIBRARY_PATH=/usr/local/lib/python3.6.1/site-packages/PySide

I tried

export PATH=/usr/local/bin:$PATH

export PATH=/usr/local/share/python:$PATH
export PATH=/usr/local/share/python3:$PATH

brew install pyqt
export PYTHONPATH=/usr/local/lib/python:$PYTHONPATH
export PYTHONPATH=/usr/local/lib/python3:$PYTHONPATH

brew install zmq
pip install pyzmq
pip install pygments

This freak error still happen

2

It looks like you installed pyside only for Python 2. There are two meta packages for pyside in the repository python-pyside and python3-pyside. You can see this for yourself with the following command which searches the repository for pyside:

sudo apt-cache search pyside

You can also confirm that it works in Python 2, by doing the following from the command line:

  1. open the python 2 terminal: python
  2. try to import the package: import PySide.QtCore

If you don't get an error the package is installed and available for Python 2.

To resolve the issue simply install the Python 3 package:

sudo apt-install python3-pyside

You should now be able to import the package into your code.

I am not a Mac user, but I would be willing to bet the solution is similar.

  • The command sudo apt-cache search pyside doesn't work . I guess this command is only for linux. – Thiago Farias Jul 13 '17 at 16:01
  • My mistake pasted the wrong command fixed in my question above sudo apt-install python3-pyside – Steve Robillard Jul 13 '17 at 16:11
  • Sorry, I didn't want to be rude. I am very noobie using Raspberry, Mac and Python. So I might make a lot of mistakes. I will search more about Mac in another sites, at least in the raspberry pi the problem was solved. Thank you Steve. I had to update before installing. – Thiago Farias Jul 13 '17 at 16:16
  • For your aMac you can try the pip install -U python-pyside or stackoverflow.com/questions/39821177/… – Steve Robillard Jul 13 '17 at 16:22
  • You should run sudo apt-get update before every install or other apt command, this ensures that you get the latest package version. – Steve Robillard Jul 13 '17 at 16:36
-1

Thank you very much Steve Robillard, your answer in the comment is the solution for this problem. Bellow, I will just explain step-by-step How I did, so it might help some beginner like me.

Update before installing python3-pyside . Do it in the order below:

In LXTerminal:

sudo apt-get update

install python3-pyside:

sudo apt-get install python3-pyside

Open Python 3 in the LXTerminal:

python3

"Call" the Pyside:

import PySide

Check the version you have just installed:

PySide.__version__
  • 1
    How is this different than my answer? – Steve Robillard Jul 13 '17 at 16:27
  • 1
    I don't usually care, but you have coopted my answer and presented it as your own not cool. – Steve Robillard Jul 13 '17 at 16:36
  • Sorry, but I think you are reading the wrong thing. Your answer there is nothing to this. You said to type sudo apt-cache search pyside (and some other instructions that unfortunately didn't work for me), whereas I just said to "update " before install (which was the only thing that worked for me). I just want to leave an answer for someone like me that spent many hours trying to find a solution that I didn't find on google. I am really thankful for you help. – Thiago Farias Jul 14 '17 at 8:22
  • Sorry, just now I saw your comment about update. I will you give you all the credits, I hadn't seen it when I post a new answer. – Thiago Farias Jul 14 '17 at 8:42

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.