Code:
python -m venv --system-site-packages env
Gives me all the system modules
Code:
arandr 0.1.11asgiref 3.6.0astroid 2.14.2asttokens 2.2.1av 10.0.0Babel 2.10.3beautifulsoup4 4.11.2blinker 1.5certifi 2022.9.24chardet 5.1.0charset-normalizer 3.0.1click 8.1.3colorama 0.4.6colorzero 2.0cryptography 38.0.4cupshelpers 1.0dbus-python 1.3.2dill 0.3.6distlib 0.3.6distro 1.8.0docutils 0.19filelock 3.9.0Flask 2.2.2gpiozero 2.0html5lib 1.1idna 3.3importlib-metadata 4.12.0isort 5.6.4itsdangerous 2.1.2jedi 0.18.2Jinja2 3.1.2lazy-object-proxy 1.9.0lgpio 0.2.2.0libevdev 0.5logilab-common 1.9.8lxml 4.9.2MarkupSafe 2.1.2mccabe 0.7.0more-itertools 8.10.0mypy 1.0.1mypy-extensions 0.4.3numpy 1.24.2oauthlib 3.2.2olefile 0.46parso 0.8.3pbr 5.10.0pexpect 4.8.0pgzero 1.2picamera2 0.3.17pidng 4.0.9piexif 1.1.3pigpio 1.78Pillow 9.4.0pip 23.0.1platformdirs 2.6.0psutil 5.9.4ptyprocess 0.7.0pycairo 1.20.1pycups 2.0.1pygame 2.1.2Pygments 2.14.0PyGObject 3.42.2pyinotify 0.9.6PyJWT 2.6.0pylint 2.16.2PyOpenGL 3.1.6pyOpenSSL 23.0.0PyQt5 5.15.9PyQt5-sip 12.11.1pyserial 3.5pysmbc 1.0.23python-apt 2.6.0python-dotenv 0.21.0python-prctl 1.8.1pytz 2022.7.1pyudev 0.24.0reportlab 3.6.12requests 2.28.1requests-oauthlib 1.3.0responses 0.18.0roman 3.3RTIMULib 7.2.1Send2Trash 1.8.1b0sense-hat 2.6.0setuptools 66.1.1simplejpeg 1.6.6simplejson 3.18.3six 1.16.0smbus2 0.4.2soupsieve 2.3.2spidev 3.5ssh-import-id 5.10stevedore 4.0.2thonny 4.1.4toml 0.10.2tomlkit 0.11.7twython 3.8.2types-aiofiles 22.1types-annoy 1.17types-appdirs 1.4types-aws-xray-sdk 2.10types-babel 2.11types-backports.ssl-match-hostname 3.7types-beautifulsoup4 4.11types-bleach 5.0types-boto 2.49types-braintree 4.17types-cachetools 5.2types-caldav 0.10types-certifi 2021.10.8types-cffi 1.15types-chardet 5.0types-chevron 0.14types-click-spinner 0.1types-colorama 0.4types-commonmark 0.9types-console-menu 0.7types-contextvars 2.4types-croniter 1.3types-cryptography 3.3types-D3DShot 0.1types-dateparser 1.1types-DateTimeRange 1.2types-decorator 5.1types-Deprecated 1.2types-dj-database-url 1.0types-docopt 0.6types-docutils 0.19types-editdistance 0.6types-emoji 2.1types-entrypoints 0.4types-first 2.0types-flake8-2020 1.7types-flake8-bugbear 22.10.27types-flake8-builtins 2.0types-flake8-docstrings 1.6types-flake8-plugin-utils 1.3types-flake8-rst-docstrings 0.2types-flake8-simplify 0.19types-flake8-typing-imports 1.14types-Flask-Cors 3.0types-Flask-SQLAlchemy 2.5types-fpdf2 2.5types-gdb 12.1types-google-cloud-ndb 1.11types-hdbcli 2.14types-html5lib 1.1types-httplib2 0.21types-humanfriendly 10.0types-invoke 1.7types-JACK-Client 0.5types-jmespath 1.0types-jsonschema 4.17types-keyboard 0.13types-ldap3 2.9types-Markdown 3.4types-mock 4.0types-mypy-extensions 0.4types-mysqlclient 2.1types-oauthlib 3.2types-openpyxl 3.0types-opentracing 2.4types-paho-mqtt 1.6types-paramiko 2.11types-parsimonious 0.10types-passlib 1.7types-passpy 1.0types-peewee 3.15types-pep8-naming 0.13types-Pillow 9.3types-playsound 1.3types-polib 1.1types-prettytable 3.4types-protobuf 3.20types-psutil 5.9types-psycopg2 2.9types-pyaudio 0.2types-PyAutoGUI 0.9types-pycurl 7.45types-pyfarmhash 0.3types-pyflakes 2.5types-Pygments 2.13types-pyinstaller 5.6types-PyMySQL 1.0types-pynput 1.7types-pyOpenSSL 22.1types-pyRFC3339 1.1types-PyScreeze 0.1types-pysftp 0.2types-pytest-lazy-fixture 0.6types-python-crontab 2.6types-python-dateutil 2.8types-python-gflags 3.1types-python-jose 3.3types-python-nmap 0.7types-python-slugify 6.1types-pytz 2022.6types-pyvmomi 7.0types-pywin32 304types-PyYAML 6.0types-redis 4.3types-regex 2022.10.31types-requests 2.28types-retry 0.9types-Send2Trash 1.8types-setuptools 65.5types-simplejson 3.17types-singledispatch 3.7types-six 1.16types-slumber 0.7types-SQLAlchemy 1.4.43types-stdlib-list 0.8types-stripe 3.5types-tabulate 0.9types-termcolor 1.1types-toml 0.10types-toposort 1.7types-tqdm 4.64types-tree-sitter 0.20types-tree-sitter-languages 1.5types-ttkthemes 3.2types-typed-ast 1.5types-tzlocal 4.2types-ujson 5.5types-urllib3 1.26types-vobject 0.9types-waitress 2.1types-whatthepatch 1.0types-xmltodict 0.13types-xxhash 3.0types-zxcvbn 4.4typing_extensions 4.4.0urllib3 1.26.12v4l2-python3 0.3.3virtualenv 20.17.1+dsvirtualenv-clone 0.3.0virtualenvwrapper 4.8.4webencodings 0.5.1Werkzeug 2.2.2wheel 0.38.4wrapt 1.14.1zipp 1.0.0
Whereas when I specify the python version while creating the virtual environment
Code:
python3.9 -m venv --system-site-packages newenv
Code:
pip 22.0.4setuptools 58.1.0
Code:
from gpiozero import AngularServofrom gpiozero.tools import sin_valuesfrom signal import pausefrom time import sleepservo=AngularServo(18, min_angle=0, max_angle=180, min_pulse_width=0.0007, max_pulse_width=0.0025)servo.angle = 0sleep(2)print("0")servo.angle = 180sleep(2)print("180")
Code:
(env2) pi@raspberrypi:~ $ python servotest.py/home/pi/env2/lib/python3.9/site-packages/gpiozero/devices.py:300: PinFactoryFallback: Falling back from lgpio: No module named 'lgpio' warnings.warn(/home/pi/env2/lib/python3.9/site-packages/gpiozero/devices.py:300: PinFactoryFallback: Falling back from rpigpio: No module named 'RPi' warnings.warn(/home/pi/env2/lib/python3.9/site-packages/gpiozero/devices.py:300: PinFactoryFallback: Falling back from pigpio: No module named 'pigpio' warnings.warn(/home/pi/env2/lib/python3.9/site-packages/gpiozero/devices.py:300: PinFactoryFallback: Falling back from native: unable to open /dev/gpiomem or /dev/mem; upgrade your kernel or run as root warnings.warn(Traceback (most recent call last): File "/home/pi/servotest.py", line 6, in <module> servo=AngularServo(18, min_angle=0, max_angle=180, min_pulse_width=0.0007, max_pulse_width=0.0025) File "/home/pi/env2/lib/python3.9/site-packages/gpiozero/devices.py", line 108, in __call__ self = super().__call__(*args, **kwargs) File "/home/pi/env2/lib/python3.9/site-packages/gpiozero/output_devices.py", line 1725, in __init__ super().__init__(pin, initial_value=initial_value, File "/home/pi/env2/lib/python3.9/site-packages/gpiozero/output_devices.py", line 1503, in __init__ pwm_device=PWMOutputDevice( File "/home/pi/env2/lib/python3.9/site-packages/gpiozero/devices.py", line 108, in __call__ self = super().__call__(*args, **kwargs) File "/home/pi/env2/lib/python3.9/site-packages/gpiozero/output_devices.py", line 392, in __init__ super().__init__(pin, active_high=active_high, initial_value=None, File "/home/pi/env2/lib/python3.9/site-packages/gpiozero/output_devices.py", line 74, in __init__ super().__init__(pin, pin_factory=pin_factory) File "/home/pi/env2/lib/python3.9/site-packages/gpiozero/mixins.py", line 75, in __init__ super().__init__(*args, **kwargs) File "/home/pi/env2/lib/python3.9/site-packages/gpiozero/devices.py", line 544, in __init__ super().__init__(pin_factory=pin_factory) File "/home/pi/env2/lib/python3.9/site-packages/gpiozero/devices.py", line 245, in __init__ Device.ensure_pin_factory() File "/home/pi/env2/lib/python3.9/site-packages/gpiozero/devices.py", line 270, in ensure_pin_factory Device.pin_factory = Device._default_pin_factory() File "/home/pi/env2/lib/python3.9/site-packages/gpiozero/devices.py", line 302, in _default_pin_factory raise BadPinFactory('Unable to load any default pin factory!')gpiozero.exc.BadPinFactory: Unable to load any default pin factory!
viewtopic.php?t=364756
Is there any workaround so that i can use the GPIO pins with python3.9 or import the system modules in the virtual environment? I'm a beginner to these sort of things. Any kind of help would be appreciated. I can provide additional information if required. Thanks in advance!
Statistics: Posted by wasedxs — Tue Mar 12, 2024 3:44 am