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

Thiago Farias
  • 145
  • 1
  • 1
  • 10

3 Answers3

3

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.

Steve Robillard
  • 34,687
  • 17
  • 103
  • 109
  • 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 https://stackoverflow.com/questions/39821177/python-pyqt-on-macos-sierra – 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
  • Sorry, just now I am reading this comment about update. I swear I did't see that. – Thiago Farias Jul 14 '17 at 08:41
0

I found a solution to this problem for python version > 3.4x, which I posted here: https://stackoverflow.com/a/65110892/12298276

Andreas L.
  • 101
  • 1
-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__
Thiago Farias
  • 145
  • 1
  • 1
  • 10
  • 2
    How is this different than my answer? – Steve Robillard Jul 13 '17 at 16:27
  • 2
    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 08: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 08:42