I am trying to install a custom Python 3 package into PyCharm. The package comes with a setup.py file. In PyCharm's Project Interpreter settings, I tried adding the local directory (according to these instructions) which contains the setup.py file but the package is not registering when I reload the list of available packages to install. Tried adding the directory which includes the .egg file but to no avail either. How am I supposed to install custom packages? Is there a command line I could use instead for PyCharm?
Using PyCharm Pro v3.4 on OSX Yosemite.
I ended up setting up a virtual environment (using virtualenvwrapper), installing the python packages there, and then pointing the Project Interpreter within PyCharm to the python version sitting within the virtual environment.
Related
After updating macOs to Monterey, every new modules I install with pip won’t be imported in my Python programs. My sis.path are good and all the packages I need are in the site-packages. Can somebody help me ?
You need to check your python environment.
try which pip3 or which python3 to check locate your active python directory.
You can have different python versions installed in macOS which often leads to this issue.
Or maybe you are using virtual environments which creates isolated site-packages. If this is intended, then you should run your script within this environment to use the packages that you've installed.
I already did pip install kivymd in my Python project. I also had the kivymd directory in my project.
I'm working with a Mac.
I created a spec file called "coinsnack4.spec" including the code below:
from kivymd import hooks_path as kivymd_hooks_path
However, when I try to package my python project with the spec file with the command:
pyinstaller -y --clean --windowed coinsnack4.spec
I got the error below:
File "coinsnack4.spec", line 3, in <module>
from kivymd import hooks_path as kivymd_hooks_path
ModuleNotFoundError: No module named 'kivymd'
I really don't know why this happens because I already pip install kivymd. I don't know what to do next and I would appreciate if anyone could help me with this error.
Thank you very much!
Why are you facing this issue?
The reason behind this is the concept of virtual environments in python. Each virtual environment is independent of the other. You can use different virtual environments, activate and deactivate them as per your project's requirements.
I would suggest you go through this doc once Python venv
As when you do a `pip install <SOME_PACKAGE> from your local terminal, it installs the package from into the default python environment and from the terminal itself (not pycharm terminal) if you try to execute the python program it will work fine but as soon as you switch to pycharm or any other IDE, it has it's own python environment set and that environment is unaware of what happened in the other python environment. So you need to install the pip package here also, in order to execute the same python program.
Solution:-
The first thing I would suggest is to install the package in the virtual environment that the pycharm is using. For that click on the Terminal icon the below bar of your pycharm window. then do run the below command :-
python3 -m pip install kivymd
If this doesn't work, try configuring the python environment in pycharm.
Below is how you can change or update your python interpreter in pycharm: -
Setting an existing Python interpreter
At any time, you can switch your Python interpreter either using the Python Interpreter selector or in the Project Settings/Preferences.
Creating a new Python interpreter
To add a new interpreter to the current project:
If you have a conda environment, follow the below steps: -
Or if you want to setup a new virtual environment, do as below: -
I think you installed pyinstaller not in project's virtualenv, just:
pip install pyinstaller
then problem will be fixed.
Having windows 10, pycharm version 4.5.4, python v3.4, django v1.8 I imported a django project existed in virtualenv directory into pycharm. Thus far I've installed several packages through the same virtualenv (using pip) like django-registration-redux etc, all being recognizable by pycharm. I installed pymongo in the same way as all the other packages but pycharm cannot recognize it although the package exists in the site-packages of the virtualenv directory and I can import it using the django manage.py shell.
I tried installing the pymongo globally and this way pycharm could recognize the package.
My question being: what pycharm doesn't recognize the pymongo package that was installed in virtualenv and how can I fix it?
Please check in your virtual environment if that package is really installed:
$ pip freeze
pymongo==<version of installed pymongo>
if it is really installed in your Virtual Environment check PyCharm settings. (Configuring Project interpreter)
Settings => Project: => Project Interpreter
Your Project interpreter should be listed there and selected for current project. If no - select it.
Also all packages installed in virtual environment will be listed there.
I have spyderlib installed on my MacOS X (10.6.8) using the official dmg file. In parallel, I have installed packages using both pip and homebrew from the terminal (i.e. opencv, gdal...). As Spyder is using its own python version, I cannot access my external packages within Spyder.
When Homebrew install a package, it instals it in the /usr/local/lib... directory, which is not avalaible to add using the Python Path manager of Spyder.The entire directory /usr/... is hidden.
The only relevant similar case I found online was the following:
Adding a module (Specifically pymorph) to Spyder (Python IDE)
I have tried unsuccessfuly their recommendations. So two related questions to tackle the problem:
1- would it be possible to actually use in Spyder the same python as the one accessed in the terminal?
2- otherwise, how to add external packages to the Spyder's original python, when the packages are installed in the folder /usr/local... ?
Thanks
I don't use a mac, but I would go with option 1, building and installing Spyder on your regular Python.
Install PyQt4 if you don't have it:
brew install pyqt
Then download the Spyder 2.2.5 source (spyder-2.2.5.zip) from here, unzip the folder where you like.
Then open a terminal, and go inside the Spyder source folder (you must input the next commands from inside this folder).
Then build using your regular python executable:
python setup.py build
and install:
python setup.py install
If all dependencies are met, you should then have Spyder as a package under your main Python installation. There should be a script to execute it under the Scripts folder.
You can also see "Install or run directly from source" from the main Spyder installation page.
I am doing some pylons work in a virtual python enviorment, I want to use MySQL with SQLalchemy but I can't install the MySQLdb module on my virtual enviorment, I can't use easyinstall because I am using a version that was compiled for python 2.6 in a .exe format, I tried running the install from inside the virtual enviorment but that did not work, any sugestions?
Ok Got it all figured out, After I installed the module on my normal python 2.6 install I went into my Python26 folder and low and behold I happened to find a file called MySQL-python-wininst which happened to be a list of all of the installed module files. Basicly it was two folders called MySQLdb and another called MySQL_python-1.2.2-py2.6.egg-info as well as three other files: _mysql.pyd, _mysql_exceptions.py, _mysql_exceptions.pyc. So I went into the folder where they were located (Python26/Lib/site-packages) and copied them to virtualenv's site-packages folder (env/Lib/site-packages) and the module was fully functional!
Note: All paths are the defaults