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
Related
i recently rescountred this problem: i can't run python apps with modules in cmd. I can install modules with pip (it works perfectly), i can run an python code, but if i use a module (installed with pip) it doesn't work with 'ModuleNotFound' error. But if I execute the code from Idle or Pycharm it works fine. How can I solve this issue?
If you have a folder other than the ones you've created( called venv or something like that) then you have a virtual environement installed in your project.Before running your code you need to activate that virtual environement by going to the directory that contains your python project and running this command:
name-of-virtual-environement\scripts\activate
The name of your virtual environement is the name of that folder so if it's venv you need to run the command
venv\scripts\activate
By default, pycharm creates virtual environements for your projects that's why whenever you create a new project and you import a module that you already used before in another project you need to install it again because that module was only installed in the virtual environement of that project and not globally.
If you never used virtual environements you might wonder why we need them. In fact, they are very useful in avoiding versions mismatch. For example if you worked in a project using Pandas version 1.3 and you installed it globally then you create a new project in which you need to use Pandas version 1.4 in that case pandas 1.3 will be removed and version 1.4 will be installed so if you try to run the first project again pandas 1.4 which can cause trouble sometimes.
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 created different virtual environments due to different dependencies requirements, one of which is running Python 2.7. I have three .py modules included in a folder, that folder is in the same directory as all my scripts. However, when I try import those three .py modules I got an error "ImportError: DLL load failed: The specified module could not be found.". I suspect that it is due to the Python Interpreter in VSCode being pointed towards my Python 2.7 virtual environment in which these three .py modules do not exist. My questions are :
How can I "install" these three modules into my virtual environment ?
Is there a quick way to install these three modules into all virtual environments ?
Thank you for your help.
You can create a setup.py, then install this folder as a module by pip
pip install -e /path/to/folder
See more at https://packaging.python.org/tutorials/packaging-projects/
Can't seem to get imports to work. I've installed using
pip install pyperclip
I can can confirm that it was successfully installed:
But then when attempt to confirm in in the Shell:
Is there another step to importing that I'm just missing?
Your problem is that pip is installing for the global (all users) version of python, and you're using a version of python installed for only your user c:\Users\bbarker\AppData\Local\Programs\Python\Python36. You'll want to either use the global install instead c:\program files (x86)\python36-32 or change your pip defaults as described here.
You'll notice the folder where pip told you where pyperclip was installed does not show up in sys.path. Therefore python does not know to search there for libraries. Those few file paths you did have in your sys.path are automatically generated defaults that are relative to the install directory of the particular instance of python you're currently using. If you use the instance in your \program files (x86)\ folder, the paths will be relative to that folder instead
tldr;
You have 2 instances of python installed, and you're installing libraries to one and using the other.
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.