Installed PySide but cant import it: no module named PySide

2024/11/14 22:41:23

I'm new to Python. I have both Python 2.7 and Python 3 installed. I just tried installing PySide via Homebrew and got this message:

PySide package successfully installed in /usr/local/lib/python2.7/site-packages/PySide...

Both versions of Python and the newly installed PySide are all stored in /usr/local/Cellar/.

This issue is that when I'm in either Python 2.7 or Python 3 and try to import PySide or run a test program that includes PySide, I get the message: "no module named PySide".

This is on OS X 10.9.3

Any help would be greatly appreciated, I've searched far and wide and tried reinstalling a few times with the same results.

The full sys.path output:

When I run while in Python 3:

>>> print(sys.path)
['', '/usr/local/Cellar/python3/3.4.1/Frameworks/Python.framework/Versions/3.4/lib/python34.zip', '/usr/local/Cellar/python3/3.4.1/Frameworks/Python.framework/Versions/3.4/lib/python3.4', '/usr/local/Cellar/python3/3.4.1/Frameworks/Python.framework/Versions/3.4/lib/python3.4/plat-darwin', '/usr/local/Cellar/python3/3.4.1/Frameworks/Python.framework/Versions/3.4/lib/python3.4/lib-dynload', '/usr/local/lib/python3.4/site-packages']

When I run while in Python 2:

>>> print sys.path
['', '/Library/Python/2.7/site-packages/distribute-0.6.49-py2.7.egg', '/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python27.zip', '/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7', '/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/plat-darwin', '/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/plat-mac', '/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/plat-mac/lib-scriptpackages', '/System/Library/Frameworks/Python.framework/Versions/2.7/Extras/lib/python', '/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/lib-tk', '/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/lib-old', '/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/lib-dynload', '/System/Library/Frameworks/Python.framework/Versions/2.7/Extras/lib/python/PyObjC', '/Library/Python/2.7/site-packages', '/Library/Python/2.7/site-packages/setuptools-0.6c11-py2.7.egg-info']
Answer

PySide was installed to /usr/local/lib/python2.7/site-packages, but Python isn’t looking there; it’s looking in /Library/Python/2.7/site-packages. Additionally, which python gave /usr/bin/python rather than /usr/local/bin/python, so you’re using the system Python.

The path forward depends on whether you want to use the system Python or Homebrew Python:

  • System Python: You’ll need to either add /usr/local/lib/python2.7/site-packages to your sys.path (possibly in /Library/Python/2.7/site.py) or move PySide to /Library/Python/2.7/site-packages.

  • Homebrew Python: You’ll need to add /usr/local/bin to your PATH, probably in ~/.bashrc.

https://en.xdnf.cn/q/71846.html

Related Q&A

How to run SQLAlchemy on AWS Lambda in Python

I preapre very simple file for connecting to external MySQL database server, like below:from sqlalchemy import *def run(event, context):sql = create_engine(mysql://root:[email protected]/scraper?chars…

saving csv file to s3 using boto3

I am trying to write and save a CSV file to a specific folder in s3 (exist). this is my code: from io import BytesIO import pandas as pd import boto3 s3 = boto3.resource(s3)d = {col1: [1, 2], col2: […

httplib2, how to set more than one cookie?

As you are probably aware, more often than not, an HTTP server will send more than just a session_id cookie; however, httplib2 handles cookies with a dictionary, like this:response, content = http.requ…

FTP upload file works manually, but fails using Python ftplib

I installed vsFTP in a Debian box. When manually upload file using ftp command, its ok. i.e, the following session works:john@myhost:~$ ftp xxx.xxx.xxx.xxx 5111 Connected to xxx.xxx.xxx.xxx. 220 Hello,…

Baktracking function which calculates change exceeds maximum recursion depth

Im trying to write a function that finds all possible combinations of coins that yield a specified amount, for example it calculates all possible way to give change for the amount 2 British pounds from…

How to interface a NumPy complex array with C function using ctypes?

I have a function in C that takes an array of complex floats and does calculations on them in-place.:/* foo.c */ void foo(cmplx_float* array, int length) {...}The complex float struct looks like this:t…

How to access predefined environment variables in conda environment.yml?

I wish to share an environment.yml file for others to reproduce the same setup as I have. The code we use depends on the environment variable $PWD. I wish to set a new env variable in the environment.y…

Python enclosing scope variables with lambda function

I wrote this simple code:def makelist():L = []for i in range(5):L.append(lambda x: i**x)return Lok, now I callmylist = makelist()because the enclosing scope variable is looked up when the nested functi…

Overloading + to support tuples

Id like to be able to write something like this in python:a = (1, 2) b = (3, 4) c = a + b # c would be (4, 6) d = 3 * b # d would be (9, 12)I realize that you can overload operators to work with custom…

Extracting particular text associated value from an image

I have an image, and from the image I want to extract key and value pair details.As an example, I want to extract the value of "MASTER-AIRWAYBILL NO:" I have written to extract the entire te…