I have developed few modules in python and I want to import them to rstudio RMarkdown file. However, I am not sure how I can do it.
For example, I can't do from code.extract_feat.cluster_blast import fill_df_by_blast as fill_df as I am used to do it in pycharm.
Any hint?
Thanks.
First I had to make a setup.py file for my project.
activate the virtual environment corresponding to my project source activate, then run python setup.py develop
Now, I can import my own python library from R as I installed it in my environment.
Related
Here is the error
import numpy
Exception has occurred: ModuleNotFoundError
No module named 'numpy'
File "C:\path\to\file\32.py", line 1, in <module>
import numpy
Let me know how did you install the NumPy package; using pip or something else?
If you have multiple python versions, i.e. 2.x and 3.x at the same time, please make sure your interpreter for the 32.py file is the version that you installed NumPy on.
To possibly fix your problem, you should first try installing it and see if there are any errors. You should also check the version of Python you are running on Windows 10, because when you update Python it sometimes switches names between py and python
As you can see, the version of Python has changed between py and python so you should try changing that first.
If this does not work, you should try finding the directory for NumPy and adding it to the system PATH in your script. The installer usually shows you the location by doing the following:
import sys
sys.path.append("<insert numpy location here>")
import NumPy
This should manually force it into finding the package. If none of this works, please tell us and we should be able to find a different solution.
Happy Coding!
If you're using a code editor like PyCharm, you could install it by clicking on
file then settings then the project interpreter setting and install new module! You can search for the module and install.
Make sure that the python version that you want to use is a Windows Environmental Variable. You can test this by running this line in your command line.
> python --version
If you get some other python version that is not the one that you wish to use you can set the python version you want by finding where exactly your Python folder is located and go into settings and set the path as a new variable (I can leave a tutorial for you). If that is too much of a hassle, the Python installers can set the python that you will install as an environmental variable for you. (You could uninstall and reinstall and make sure that you allow it to make it an environmental variable.
After that you should be able to import whatever external packages you want using pip
for example:
pip install numpy
I tried to load the movie_lens dataset using the code below
from lightfm.datasets import fetch_movielens
running this i am getting:
ImportError: No module named 'lightfm.datasets'; 'lightfm' is not a package
It sounds like the lightfm package is not installed in your environment. You can check in File>Project Structure>SDKs make sure lightfm is present in the Packages tab of the environment you're using for your project. Otherwise you can add the package from that same window.
since i have already tried many ways and failed,finally i run my python terminal from the default python3.5 saved folder -->for me it is /usr/bin ,then i created a new project in pycharm IDE ,istalled lightfm using pip3 it worked there too ,now i can import LightFM
I'm struggling to figure out how to include the PyQt module in my Python project. I have tried downloading it from here as a zip file, then including that directory in an environment variable that I called PYTHONPATH. I am running Windows 10, Python 3.5.1, and using PyCharm for my IDE. I was trying to follow the instructions from this question on stackoverflow but I haven't had success and am clearly unsure how to do it.
When I downloaded Python, it was downloaded to my appData folder. The path is as follows users/me/AppData/Local/Programs/Python/Python 35-32...and then a bunch of stuff is in therefor Python. I downloaded the PyQt zip folder and unzipped it to the users/me/AppData/Local/Programs/Python/. After adding the environment variable, PyCharm still isn't able to use the module saying ImportError: No module named 'PyQt4. Can anyone explain how I can import this module successfully? I'm used to Javascript...is there a way to just reference the file? Kind of like how this other stack overflow question is doing it?
Here are the imports that I need:
from PyQt4.QtGui import *
from PyQt4.QtCore import *
from PyQt4.QtWebKit import *
Thanks in advance!
This is how i install Python and PyQt
1 - Install python (Create a folder somewhere like D:\python_dist)
2 - Install Qt
3 - Install PyQt5/PyQt4 with Windows installer ( PyQt5-5.6-gpl-Py3.5-Qt5.6.0-x64-2.exe) https://www.riverbankcomputing.com/software/pyqt/download5
4 - Check paths ...
5 - Open your IDE then try
When you do python, usually you use a virtual_env, and you could need several env, that's why i recommand to create a special python folder
If you are having trouble installing the PyQt library from binary and from pip you could install PyQt from prepackaged whl files.
navigate to the Unofficial Windows Binaries from the University of California, Irvine and download the whl associated with your installed version of Python:
http://www.lfd.uci.edu/~gohlke/pythonlibs/#pyqt4
Then insall that file via pip by navigating to the directory where you downloaded the whl file via command line and typing in the following:
pip install name-of-whl-file.whl
You also may have to install pip. If that is the case visit this site to learn how to do that:
https://pip.pypa.io/en/stable/installing/
Since python is bundled with the Tide SDK, I can't figure out how to use access external modules. I've tried copying the module folder "Lib/site-packages/YourModuleHere" to the tide SDK directory, and this suggestion here: TIdeSDK Python module import but with no success. The module I'm trying to use is https://github.com/burnash/gspread
Any ideas?
Thanks...
You may try http://www.py2exe.org/index.cgi/Tutorial
to convert your python code to exe with all needed modules then use Ti.Process.createProcess() to call your exe
In current version of TideSDK, loading custom python modules is not supported.It loads default set of Python modules compiled within the SDK.
I've had some luck installing a view external modules by running setup.py install from TideSDK's python.exe
This post helped:
Installing python modules in TideSDK
For Windows 7:
launch powershell
cd into the module folder
run:
C:\ProgramData\TideSDK\Modules\python\1.3.1-beta\python.exe setup.py install
It installs the module in \Lib\site-packages, as it should, and I'm able to use the import function in the python code.
This has worked for PIL and I'm trying to get it to function with pywin32. I'd love to hear if it works for other modules
I'm running Windows 7, Python 2.6.4 and the latest version of Eclipse. I downloaded the boto library (http://code.google.com/p/boto/) and ran python setup.py install, which created boto-1.9b-py2.6.egg in C:\Python26\Lib\site-packages.
Importing a class - say, by doing 'from boto.sqs.connection import SQSConnection' - works fine from the python command line tool. But Eclipse will not find boto, despite the fact that it is using the same python interpreter as I am using when at the command line. I added the library as an external source folder, but that didn't work either. How can I properly import the boto library into Eclipse?
Thanks.
From the comment so can be marked as answered
In Preferences->Pydev->interpreter - Python what is the System libs value
For libraries that are required only in a single project, the best practice is to add them to the Project's PYTHONPATH and not the SYSTEM PYTHONPATH.
This is done by right clicking on the project -> Properties -> PyDev-PYTHONPATH -> External Libraries and then adding the required library using Add zip/jar/egg.