I am writing a Merchant Data Export API in Python (Pydev plugin for eclipse) and I cannot import requests, is there some option for managing imports?
I have the requests-master folder in my project, downloaded from GitHub. I have read the following articles for downloadingand installing, but nothing works for me.
I am a new python user but would like to learn more.
Thanks for any help!
If you just do a pip install requests, things should work (the issue is that you probably aren't adding the proper folder to the PYTHONPATH for PyDev to recognize the requests module you downloaded... using pip should do the right thing for you without requiring further configurations).
Related
So long story short. I want to use requests and bs4 modules in my code. I installed them using pip install requests, pip install bs4. I double checked everything, even found installation folder and saw that the files is here, but my vs code is not detecting it and giving a error. I'm a quite new to this programming language so possibly it's a common issue. But i searched and mostly found posts about this problems on diffrent versions of linux, not windows.
Error i'm getting in vscode btw
Import "requests" could not be resolved from source
And when i'm launching the program through cmd the error is
ModuleNotFoundError: No module named 'requests'
First, you should add more information for us to know how your computer and IDE are configured. The first thing you should do is to check that VS Code is using the Python version where you have pip installed the modules. That is, clicking at the bottom-left space as in the picture below. Then checking that the modules are within that path.
Otherwise, check out virtualenv. With this tool you can create virtual environments within your project's folder and makes it easier to manage packages.
I am relatively new to programming and posting to Stack Overflow. Please forgive my ignorance.
I am attempting to use a third party module in a program of my own, however I can't work out how to access the module within my Python script.
Mac OS X Sierra 10.12.4
Python 3.6.1
Anaconda 4.3.1
Specifically, I would like to be able to access anki (https://github.com/dae/anki).
I initially tried the line:
from anki import Collection
That resulted in a 'ModuleNotFoundError'.
Next I tried:
conda install anki
which also didn't work and yielded a 'PackageNotFoundError'
After more searching, I decided to try:
import sys
sys.path.append('usr/share/anki')
from anki import Collection
However, this also results in a 'ModuleNotFoundError'
What do I need to do to be able to access this module?
I am sure that it is possible because I have come across several other programs which make use of it:
-https://eshapard.github.io/anki/open-the-anki-database-from-python.html
I recognize that the link above purports to offer a solution to exactly this problem, however the solution proffered isn't working for me. Thanks in advance.
You are telling about Anki for desktop computers, which IS application written in Python, but it is NOT an installable Python package.
So the commands like
conda install anki
or
pip install anki
have no meaning.
So the only way is to download full source code of this project, unzip the content of it (only) folder into your project (change you actual folder to it) and then you may do import commands.
I'm a complete beginner in Python programming. I have trouble installing/importing the module 'requests' on python. When I use my command terminal to install requests, I get a message that requests is already installed. However, when I try to import requests into the file I'm working on, python tells me there is no such module installed.
Sorry to bother you with this silly and probably easy question, thanks in advance!
If you use PyCharm (which is a great choice in my opinion), go to the tab Run and select Edit Configuration and in the window that just opened make sure the your Python interpreter is the one you used when you pip installed the package you asked about.
You can check your Python version or just see in PyCharm if the requests is actually installed by going to the tab File, select Settings, click on Project: name_of_your_project and finally check in Project Interpreter that the package is installed.
I'm using netbeans to write a simple python program which I need the requests module for, I've downloaded requests through terminal and it all seems to be fine there but netbeans can't seem to find it.
This is the error that it's throwing up:
import requests
ImportError: No module named requests
I've tried installing the requests library directly into the python folder but the folder won't let me paste anything into it.
There do seem to be answers on the netbeans forums but their server is down so won't let me on their website to my annoyance!
EDIT
I've tried to run python setup.py install as per other answers on the website but had no luck.
EDIT
have tried completely uninstalling python and requests to make sure it wasn't an installation error but still no luck.
This clearly looks like an error of installation of the request module to some other place than where your netbeans expects when running the code.
In your console run
which python
Check if this gives the same path as the one set in your netbeans. You can set your path by adding new platform using Tools > Python Platforms > New:
I would suggest that you learn bit more about sandboxed environments such as virtualenv. This article shows how you can use a virtualenv to install packages and use the same virtualenv for netbeans so that whatever packages you install in the virtualenv will be available in the netbeans for you to use. For this case, it could be requests.
In the end I gave up with requests, as I was using requests to get json data from an API I decided just to go back to the drawing board and start over rather than attempt to fix something that I couldn't work out. I am now using the urllib import and whilst this may not be the most efficient way it works which is the most important thing.
Our project is a mostly J2EE based development with the automatic functional and integration tests written in Python. The test environment is Linux nonetheless developers use Windows 7 (64-bit). We would like to be able to execute the functional tests on the developer machines as well (before comitting). Unfortunately the pexpect-windows-portability issue would leave us no choice but:
To do some serious refactoring on our test libraries to be able to use both winpexpect (or wexpect) and pexpect depending on the os settings.
Or to use cygwin. Guess what, with this second option we seem to have an issue :-) Using Python 2.7.5 on Cygwin64 installing the requests package results in error:
pip says it can not find a file after downloading and extracting the library
easy install doesn't throw an explicit error, but leaves everything in the temporary dir
after copying the files under the site-packages directory a simple import requests in python causes the interpreter to exit
Has anybody encountered this problem? With Cygwin-32 requests install smoothly. (however we have some other issues - see my next post ;-))
Thank you in advance: Joe, the public
Also ran into the same issues when trying to install requests, all the options on http://docs.python-requests.org/en/latest/user/install/#install did not work. I went to https://github.com/kennethreitz/requests and then clicked on "Download Zip" and I got requests-master.zip.
Update: This should be fixed in Cygwin.
This was a bug in CPython that has been fixed in their master branch. I've pushed a candidate package to the Python maintainer for Cygwin, but you might try this hotfix.
I downloaded from "https://github.com/requests/requests" and then i just ran the setup.py from the requests-master folder ( this was placed in cygwin folder). After that I went to cygwin terminal and then I ran python --> import requests. Voila it worked.