• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Tim Cooke
  • paul wheaton
  • Liutauras Vilda
  • Ron McLeod
Sheriffs:
  • Jeanne Boyarsky
  • Devaka Cooray
  • Paul Clapham
Saloon Keepers:
  • Scott Selikoff
  • Tim Holloway
  • Piet Souris
  • Mikalai Zaikin
  • Frits Walraven
Bartenders:
  • Stephan van Hulst
  • Carey Brown

Is there way to resolve pymysql import using PyMySQL-1.0.3-py3-none-any.whl without pip install

 
Ranch Hand
Posts: 2954
13
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I have having in a python class. At the same path in the project I pasted PyMySQL-1.0.3-py3-none-any.whl downloaded from https://pypi.org/project/pymysql/#files.

However, it still gives "No module named 'pymysql' ".

I know one way to resolve it. If I do pip install pymysql at the same same path as the above python file, this import gets resolved.

Is pip install required or it can be resolved using the wheel file (PyMySQL-1.0.3-py3-none-any.whl) itself. If so what is the way?
Thanks
 
Saloon Keeper
Posts: 28396
210
Android Eclipse IDE Tomcat Server Redhat Java Linux
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
No, pip install isn't required, but it's one of the easier ways to install a python package. If I'm remembering correctly, if you unzip a whl, there's a "setup.py" that you can run.

Alternatively, if you're running a heavily packaged OS like Linux, a lot of the popular python packages can also be installed via the OS package installer (apt or yum/dnf). That has the advantage of registering them in the OS package database for auditing purposes and of course also for stuff like package repair and intrusion detection.
 
Monica Shiralkar
Ranch Hand
Posts: 2954
13
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thanks. Now this is what I am trying to understand. Like in java if some import gives error saying cannot resolve, we check that which dependency will resolve it and add that in maven and the import gets resolved, or we download that jar and put that in the lib folder and then the import gets resolved. What is the right way in python? Is it to do the pip install into the folder where the python file having this import is or is it to download the wheel file, extract it and run the setup.py into the folder where this python file is ? .
 
Tim Holloway
Saloon Keeper
Posts: 28396
210
Android Eclipse IDE Tomcat Server Redhat Java Linux
  • Likes 1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Ideally your project will include dependencies in the wheel manifest file, in which case pip will automatically install them similar to Maven.

Python is not Java, however. Maven downloads dependencies into a user's local cache and copies are made of the dependent JAR when building assemblies. Python, on the other hand doesn't cache. Instead it references the actual downloaded and unpacked dependency from its PYTHONPATH.

Python/pip also has the option to install into the system global python resources directory (requires root privileges) or to the user's local python resources, or, I believe, to a virtual python environment, although I've never really explored that one.
 
Monica Shiralkar
Ranch Hand
Posts: 2954
13
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Tim Holloway wrote:Ideally your project will include dependencies in the wheel manifest file, in which case pip will automatically install them similar to Maven.


Thanks. "Pip will automatically install' means? What do we have to do from our end related to pip?
 
Tim Holloway
Saloon Keeper
Posts: 28396
210
Android Eclipse IDE Tomcat Server Redhat Java Linux
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
If you run pip on a package with dependencies, pip will download and install the package and its dependencies.
 
Monica Shiralkar
Ranch Hand
Posts: 2954
13
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thanks. Found the command.

 
Politics n. Poly "many" + ticks "blood sucking insects". Tiny ad:
Gift giving made easy with the permaculture playing cards
https://coderanch.com/t/777758/Gift-giving-easy-permaculture-playing
reply
    Bookmark Topic Watch Topic
  • New Topic